#include <bits/stdc++.h>
using namespace std;
const long long BIGER = 1000000000000000;
const int BIG = 1000000000;
const int MOD = 1000000007;
int n;
int b[10001];
bool f[2005][2005];
bool used[2005];
int a[10001];
int g = 0;
int ypa(int k) {
  if (k == n + 1) {
    g++;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (f[a[k - 1]][i] != 1 && used[i] != 1) {
      used[i] = 1;
      a[k] = i;
      ypa(k + 1);
      used[i] = 0;
    }
  }
}
int main() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> b[i];
    f[b[i]][i] = 1;
    f[i][b[i]] = 1;
  }
  ypa(1);
  cout << g;
  return 0;
}
