#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <bitset>
const int maxn = 1e3 + 20;
struct Edge {
int u, v, tonext;
}e[maxn * 2];
int first[maxn], num;
void addEdge(int u, int v) {
++num;
e[num].u = u, e[num].v = v, e[num].tonext = first[u];
first[u] = num;
}
int dp[maxn];
vector<int>vc[maxn];
int dfs(int cur, int fa) {
int son = 0;
vc[cur].clear();
for (int i = first[cur]; i; i = e[i].tonext) {
int v = e[i].v;
if (fa == v) continue;
son++;
vc[cur].push_back(dfs(v, cur));
}
if (vc[cur].size() == 0) return 0;
sort(vc[cur].begin(), vc[cur].end());
for (int i = 0; i < vc[cur].size(); ++i) {
vc[cur][i] += son;
son--;
}
sort(vc[cur].begin(), vc[cur].end());
return vc[cur].back();
}
struct Node {
int val, id;
Node(int _val, int _id) {
val = _val, id = _id;
}
bool operator < (const struct Node & rhs) const {
if (val != rhs.val) return val < rhs.val;
else return id < rhs.id;
}
};
vector<struct Node>res;
void work() {
num = 0;
memset(first, 0, sizeof first);
int n;
scanf("%d", &n);
int root = 1;
for (int i = 2; i <= n; ++i) {
int fa;
scanf("%d", &fa);
addEdge(fa, i);
addEdge(i, fa);
}
for (int i = 1; i <= n; ++i) {
res.push_back(Node(dfs(i, 0) + 1, i));
}
// for (int i = 0; i <= n - 1; ++i) {
// cout << res[i] << endl;
// }
sort(res.begin(), res.end());
int mi = res[0].val;
printf("%d\n", mi);
for (int i = 0; i < res.size(); ++i) {
if (mi == res[i].val) {
printf("%d ", res[i].id);
} else break;
}
}
int main() {
#ifdef local
freopen("data.txt", "r", stdin);
// freopen("data.txt", "w", stdout);
#endif
work();
return 0;
}