#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#ifdef LOCAL
#define debug(x) {cerr <<#x <<" = " <<x <<"\n"; }
#define debug2(x, y) {cerr <<#x <<" = " <<x <<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z) {cerr <<#x <<" = " <<x <<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
using std::cerr;
#else
#define debug(x)
#define debug2(x, y)
#define debug3(x, y, z)
#define debugv(x)
#define cerr if(0)cout
#endif
#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;
using std::endl;
using std::cout;
using std::cin;
using std::vector;
using std::set;
using std::map;
using std::pair;
using std::max;
using std::min;
using std::ostream;
using std::fixed;
using std::ios_base;
using std::setprecision;
using std::make_pair;
using std::string;
using std::multiset;
using std::next_permutation;
using std::prev_permutation;
using std::random_shuffle;
using std::greater;
using std::lower_bound;
using std::upper_bound;
using std::reverse;
using std::swap;
using std::complex;
using std::sort;
using std::bitset;
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}

const int N = 1e5 + 5;
const int P = 1e9 + 7;
int dp[N][2];
vector<int> slo[N];
int p[N];
void Dfs(int v) {
  for (auto nei : slo[v]) {
    Dfs(nei);
  }
  int dp_all[2] = {};
  int dp_even = 1;
  int dp_odd_even = 1;
  int dp_odd_odd = 0;
  dp_all[1] = 1;
  for (auto nei : slo[v]) {
    dp_even = (dp_even * dp[nei][0]) % P;
    int tmp = dp_odd_even;
    dp_odd_even = (dp_odd_even + dp_odd_odd * dp[nei][1]) % P;
    dp_odd_odd = (dp_odd_odd + tmp * dp[nei][1]) % P;
    int new_dp[2] = {};
    REP (par_so_far, 2) {
      REP (son_par, 2) {
        new_dp[par_so_far ^ son_par] += dp_all[par_so_far] * dp[nei][son_par];
      }
    }
    REP (i, 2) {
      dp_all[i] = new_dp[i] % P;
    }
  }
  debug(v);
  debug(dp_even);
  debug(dp_odd_even);
  debug(dp_odd_odd);
  dp[v][0] = (1 + 2 * dp_all[0] - dp_odd_odd + P) % P;
  dp[v][1] = (2 * dp_all[1] - dp_even + P) % P;
  //dp[v][0] = (1 + 2 * dp_all[0] - dp_even + P) % P;
  //dp[v][1] = (2 * dp_all[1] - dp_odd_odd + P) % P;
  debug(dp_all[0]);
  debug(dp_all[1]);
  debug(dp[v][0]);
  debug(dp[v][1]);
  return;
}
#undef int
int main() {
#define int long long

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;

  make(int, n);
  FOR (i, 2, n) {
    cin>>p[i];
    slo[p[i]].PB(i);
  }
  Dfs(1);

  cout<<(dp[1][0] + dp[1][1] + P - 1) % P<<endl;

  return 0;
}


#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#ifdef LOCAL
#define debug(x) {cerr <<#x <<" = " <<x <<"\n"; }
#define debug2(x, y) {cerr <<#x <<" = " <<x <<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z) {cerr <<#x <<" = " <<x <<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
using std::cerr;
#else
#define debug(x)
#define debug2(x, y)
#define debug3(x, y, z)
#define debugv(x)
#define cerr if(0)cout
#endif
#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;
using std::endl;
using std::cout;
using std::cin;
using std::vector;
using std::set;
using std::map;
using std::pair;
using std::max;
using std::min;
using std::ostream;
using std::fixed;
using std::ios_base;
using std::setprecision;
using std::make_pair;
using std::string;
using std::multiset;
using std::next_permutation;
using std::prev_permutation;
using std::random_shuffle;
using std::greater;
using std::lower_bound;
using std::upper_bound;
using std::reverse;
using std::swap;
using std::complex;
using std::sort;
using std::bitset;
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}

const int N = 1e5 + 5;
const int P = 1e9 + 7;
int dp[N][2];
vector<int> slo[N];
int p[N];
void Dfs(int v) {
  for (auto nei : slo[v]) {
    Dfs(nei);
  }
  int dp_all[2] = {};
  int dp_even = 1;
  int dp_odd_even = 1;
  int dp_odd_odd = 0;
  dp_all[0] = 1;
  for (auto nei : slo[v]) {
    dp_even = (dp_even * dp[nei][0]) % P;
    int tmp = dp_odd_even;
    dp_odd_even = (dp_odd_even + dp_odd_odd * dp[nei][1]) % P;
    dp_odd_odd = (dp_odd_odd + tmp * dp[nei][1]) % P;
    int new_dp[2] = {};
    REP (par_so_far, 2) {
      REP (son_par, 2) {
        new_dp[par_so_far ^ son_par] += dp_all[par_so_far] * dp[nei][son_par];
      }
    }
    REP (i, 2) {
      dp_all[i] = new_dp[i] % P;
    }
  }
  debug(v);
  debug(dp_even);
  debug(dp_odd_even);
  debug(dp_odd_odd);
  dp[v][0] = (2 * dp_all[0] - dp_even + P) % P;
  dp[v][1] = (1 + 2 * dp_all[1] - dp_odd_odd + P) % P;
  debug(dp_all[0]);
  debug(dp_all[1]);
  debug(dp[v][0]);
  debug(dp[v][1]);
  return;
}
#undef int
int main() {
#define int long long

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;

  make(int, n);
  FOR (i, 2, n) {
    cin>>p[i];
    slo[p[i]].PB(i);
  }
  Dfs(1);

  cout<<(dp[1][0] + dp[1][1] + P - 1) % P<<endl;

  return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <memory.h>
#include <stdlib.h>
#include <ctype.h>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(b)-1;i>=a;i--)
#define ALL(v) v.begin(),v.end()
const int INF = 0x7FFFFFFF;

const int MAXN = 131072;
const LL MOD = 1000000007;

LL even[MAXN];
LL odd[MAXN];
vector<int> ve[MAXN];

void calc(int v) {
  even[v] = 0;
  odd[v] = 1;
  LL onlyEven = 1;
  LL onlyOdd0 = 1;
  LL onlyOdd1 = 0;
  for (int c : ve[v]) {
    LL neven = even[v] + even[v] * even[c] % MOD + odd[v] * odd[c] % MOD;
    LL nodd = odd[v] + even[v] * odd[c] % MOD + odd[v] * even[c] % MOD;
    even[v] = neven % MOD;
    odd[v] = nodd % MOD;
    onlyEven = onlyEven * (1 + even[c]) % MOD;
    LL no0 = onlyOdd0 + onlyOdd1 * odd[c] % MOD;
    LL no1 = onlyOdd1 + onlyOdd0 * odd[c] % MOD;
    onlyOdd0 = no0 % MOD;
    onlyOdd1 = no1 % MOD;
  }
  even[v] = (even[v] * 2 + MOD - onlyOdd1) % MOD;
  odd[v] = (odd[v] * 2 + MOD - onlyEven) % MOD;
}

int main() {
  int n;
  scanf("%d", &n);
  FOR(i, 1, n) {
    int p; scanf("%d", &p);
    ve[p - 1].push_back(i);
  }
  ROF(i, 0, n) calc(i);
  printf("%d", int((even[0] + odd[0]) % MOD));
  return 0;
}


#include <bits/stdc++.h>
using LL = long long;

const int N = 100000 + 5;
const int MOD = (int)1e9+7;
int n,dp[N][2];
std::vector<int> edges[N];

inline void add(int &a,int b) {
	a += b; if (a >= MOD) a -= MOD;
}

void dfs(int u) {
	for (int v : edges[u])
		dfs(v);
	int left[2] = {0,0};
	int right[2] = {0,0};
	int sym[2] = {0,0};
	int mex = 0;
	for (int v : edges[u]) {
		int tmp[2] = {left[0],left[1]};
		for (int i = 0; i < 2; ++ i)
			for (int j = 0; j < 2; ++ j)
				add(tmp[i^j^1],(LL)left[i]*dp[v][j]%MOD);
		add(tmp[0],dp[v][0]);
		add(tmp[1],dp[v][1]);
		left[0] = tmp[0];
		left[1] = tmp[1];
	}
	std::reverse(edges[u].begin(),edges[u].end());
	for (int v : edges[u]) {
		int tmp[2] = {right[0],right[1]};
		for (int i = 0; i < 2; ++ i)
			for (int j = 0; j < 2; ++ j)
				add(tmp[i^j^1],(LL)right[i]*dp[v][j]%MOD);
		add(tmp[0],dp[v][0]);
		add(tmp[1],dp[v][1]);
		right[0] = tmp[0];
		right[1] = tmp[1];
	}
	for (int v : edges[u]) {
		int tmp[2] = {sym[0],sym[1]};
		for (int i = 0; i < 2; ++ i)
			add(tmp[i^1],(LL)sym[i]*dp[v][0]%MOD);
		add(tmp[0],dp[v][0]);
		sym[0] = tmp[0];
		sym[1] = tmp[1];
	}
	for (int v : edges[u]) {
		add(mex,(LL)mex*dp[v][1]%MOD);
		add(mex,dp[v][1]);
	}

	dp[u][0] = (left[0] + right[0]) % MOD;
	dp[u][1] = (left[1] + right[1]) % MOD;
	add(dp[u][0],MOD-sym[0]);
	add(dp[u][1],MOD-mex);
	std::swap(dp[u][0],dp[u][1]);
	add(dp[u][0],1);
}

int main() {
	scanf("%d",&n);
	for (int i = 1; i < n; ++ i) {
		int x;
		scanf("%d",&x); x --;
		edges[x].push_back(i);
	}
	dfs(0);
	int answer = 0;
	add(answer,dp[0][0]);
	add(answer,dp[0][1]);
	printf("%d\n",answer);
	return 0;
}


//why are you stalking me?
#include <bits/stdc++.h>

using namespace std;

#define fillchar(a, s) memset((a), (s), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define rep(it, v) for (auto it = (v).begin(); it != (v).end(); it++)
#define dbg(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 100010, MOD = 1e9 + 7;

int add (int x, int y) {
	return (x + y) % MOD;
}

void addeq (int &x, int y) {
	x = add(x, y);
}

int subtr (int x, int y) {
	return (x -= y) < 0 ? x + MOD : x;
}

void subtreq (int &x, int y) {
	x = subtr(x, y);
}

int mult (int x, int y) {
	return ll(x) * y % MOD;
}

void multeq (int &x, int y) {
	x = mult(x, y);
}

int N;
vector<int> adj[MAXN];
int dp[MAXN][2];

void dfs (int x, int p) {
	if (adj[x].empty()) {
		dp[x][1] = 1;
		return;
	}
	//just add the children
	int *ways = dp[x];
	ways[1] = 1;
	for (int t : adj[x]) {
		dfs(t, x);
		//combine it
		int nfd[2] = {0, 0};
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				addeq(nfd[i ^ j], mult(ways[i], dp[t][j]));
			}
		}
		for (int i = 0; i < 2; i++) {
			addeq(ways[i], nfd[i]);	//you can exclude
		}
	}
	for (int i = 0; i < 2; i++) {
		multeq(ways[i], 2);
	}
	//...and subtract doublecounts.
	//all of them even, or an odd number of odds
	int dp2[2][2] = {{1, 0}, {1, 0}};
	for (int t : adj[x]) {
		int ndp[2][2] = {{0, 0}, {0, 0}};
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				ndp[i][j] = add(dp2[i][j], mult(dp[t][i], dp2[i][!j]));
			}
		}
		//update
		memcpy(dp2, ndp, sizeof(ndp));
	}
	subtreq(ways[0], dp2[1][1]);
	subtreq(ways[1], add(dp2[0][0], dp2[0][1]));
}

int main() {
	//why are you stalking me?
	if (fopen("input.txt", "r")) {
		freopen("input.txt", "r", stdin);
	}
	ios::sync_with_stdio(false);
	cin >> N;
	for (int i = 2, p; i <= N; i++) {
		cin >> p;
		adj[p].push_back(i);
	}
	for (int i = 1; i <= N; i++) {
		sort(all(adj[i]));
	}
	dfs(1, 0);
	cout << add(dp[1][0], dp[1][1]) << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define mod 1000000007

int n, head[N];
long long f[N][2];

struct data {
	int next, to;
} edge[N];

inline void add(int x, int y)
{
	static int cnt = 0;
	edge[++cnt].to = y;
	edge[cnt].next = head[x];
	head[x] = cnt;
}

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch-'0'; ch = getchar(); }
	return x * f;
}

int main()
{
	cin >> n;
	for (int x, i = 2; i <= n; ++i)
		x = read(), add(x, i);
	for (int x = n; x; --x)
	{
		f[x][0] = 0; f[x][1] = 1;
		if (!head[x]) continue;
		for (int i = head[x]; i; i = edge[i].next)
		{
			int y = edge[i].to, t0 = f[x][0], t1 = f[x][1];
			f[x][0] += t0 * f[y][0] % mod + t1 * f[y][1] % mod;
			f[x][1] += t0 * f[y][1] % mod + t1 * f[y][0] % mod;
			f[x][0] %= mod; f[x][1] %= mod;
		}
		f[x][0] *= 2; f[x][1] *= 2;
		f[x][0] %= mod; f[x][1] %= mod;
		long long cnt = 1, cnt0 = 1, cnt1 = 0;
		for (int i = head[x]; i; i = edge[i].next)
		{
			int y = edge[i].to, t0 = cnt0, t1 = cnt1;
			cnt += cnt * f[y][0] % mod;
			cnt0 += t1 * f[y][1] % mod;
			cnt1 += t0 * f[y][1] % mod;
			cnt %= mod; cnt0 %= mod; cnt1 %= mod;
		}
		f[x][0] -= cnt1; f[x][1] -= cnt;
		f[x][0] = (f[x][0] % mod + mod) % mod;
		f[x][1] = (f[x][1] % mod + mod) % mod;
	}
	cout << (f[1][0] + f[1][1]) % mod << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define mod 1000000007

int n, head[N];
long long f[N][2];

struct data {
	int next, to;
} edge[N];

inline void add(int x, int y)
{
	static int cnt = 0;
	edge[++cnt].to = y;
	edge[cnt].next = head[x];
	head[x] = cnt;
}

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch-'0'; ch = getchar(); }
	return x * f;
}

int main()
{
	cin >> n;
	for (int x, i = 2; i <= n; ++i)
		x = read(), add(x, i);
	for (int x = n; x; --x)
	{
		f[x][0] = 0; f[x][1] = 1;
		if (!head[x]) continue;
		for (int i = head[x]; i; i = edge[i].next)
		{
			int y = edge[i].to, t0 = f[x][0], t1 = f[x][1];
			f[x][0] += t0 * f[y][0] % mod + t1 * f[y][1] % mod;
			f[x][1] += t0 * f[y][1] % mod + t1 * f[y][0] % mod;
			f[x][0] %= mod; f[x][1] %= mod;
		}
		f[x][0] *= 2; f[x][1] *= 2;
		f[x][0] %= mod; f[x][1] %= mod;
		long long cnt = 1, cnt0 = 1, cnt1 = 0;
		for (int i = head[x]; i; i = edge[i].next)
		{
			int y = edge[i].to, t0 = cnt0, t1 = cnt1;
			cnt += cnt * f[y][0] % mod;
			cnt0 += t1 * f[y][1] % mod;
			cnt1 += t0 * f[y][1] % mod;
			cnt %= mod; cnt0 %= mod; cnt1 %= mod;
		}
		f[x][0] -= cnt1; f[x][1] -= cnt;
		f[x][0] = f[x][0] % mod + mod % mod;
		f[x][1] = f[x][1] % mod + mod % mod;
	}
	cout << (f[1][0] + f[1][1]) % mod << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <cstring>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define MAXN 100010
#define MOD 1000000007

vector<int> E[MAXN];

struct ctr {
  ctr() {
    memset(A, 0, sizeof(A));
  }
  ctr operator*(const ctr& x) const {
    ctr nv;
    for(int i = 0; i < 2; i++) {
      for(int j = 0; j < 2; j++) {
        for(int k = 0; k < 2; k++) {
          nv.A[i][j] = (nv.A[i][j] + 1LL * A[i][k] * x.A[k][j]) % MOD;
        }
      }
    }
    return nv;
  }
  ctr operator+(const ctr& x) const {
    ctr nv;
    for(int i = 0; i < 2; i++) {
      for(int j = 0; j < 2; j++) {
        nv.A[i][j] = (A[i][j] + x.A[i][j]) % MOD;
      }
    }
    return nv;
  }
  void print() {
    cout << A[0][0] << ' ' << A[0][1] << endl;
    cout << A[1][0] << ' ' << A[1][1] << endl;
  }
  int A[2][2];
};

ctr memo[MAXN];

ctr solve(int x) {
  if (memo[x].A[0][0] != -1) {
    return memo[x];
  }

  ctr r1, r2;
  r1.A[0][1] = r2.A[0][1] = 1;
  r1.A[1][0] = r2.A[1][0] = 1;

  for(int i = 0; i < E[x].size(); i++) {
    r1 = r1 + r1 * solve(E[x][i]);
  }
  for(int i = E[x].size() - 1; i >= 0; i--) {
    ctr res = solve(E[x][i]);
    r1.A[0][0] = (r1.A[0][0] + 1ll * r2.A[0][0] * res.A[0][0]) % MOD;
    r1.A[0][1] = (r1.A[0][1] + 1ll * r2.A[0][0] * res.A[0][1]) % MOD;
    r1.A[1][0] = (r1.A[1][0] + 1ll * r2.A[1][1] * res.A[1][0]) % MOD;
    r1.A[1][1] = (r1.A[1][1] + 1ll * r2.A[1][1] * res.A[1][1]) % MOD;
    r2 = r2 + r2 * res;
  }

  memo[x] = r1;
  return r1;
}

int main() {
  int N;
  cin >> N;
  for(int i = 1; i < N; i++) {
    int p;
    cin >> p;
    E[p - 1].push_back(i);
  }

  memset(memo, -1, sizeof(memo));
  ctr result = solve(0);
  cout << (result.A[0][0] + result.A[0][1]) % MOD << endl;
  return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <cstring>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define MAXN 100010
#define MOD 1000000007

vector<int> E[MAXN];

struct ctr {
  ctr() {
    memset(A, 0, sizeof(A));
  }
  ctr operator*(const ctr& x) const {
    ctr nv;
    for(int i = 0; i < 2; i++) {
      for(int j = 0; j < 2; j++) {
        for(int k = 0; k < 2; k++) {
          nv.A[i][j] = (nv.A[i][j] + 1LL * A[i][k] * x.A[k][j]) % MOD;
        }
      }
    }
    return nv;
  }
  ctr operator+(const ctr& x) const {
    ctr nv;
    for(int i = 0; i < 2; i++) {
      for(int j = 0; j < 2; j++) {
        nv.A[i][j] = (A[i][j] + x.A[i][j]) % MOD;
      }
    }
    return nv;
  }
  void print() {
    cout << A[0][0] << ' ' << A[0][1] << endl;
    cout << A[1][0] << ' ' << A[1][1] << endl;
  }
  int A[2][2];
};

ctr memo[MAXN];

ctr solve(int x) {
  if (memo[x].A[0][0] != -1) {
    return memo[x];
  }

  ctr r1, r2;
  r1.A[0][1] = r2.A[0][1] = 1;
  r1.A[1][0] = r2.A[1][0] = 1;

  for(int i = 0; i < E[x].size(); i++) {
    r1 = r1 + r1 * solve(E[x][i]);
  }
  for(int i = E[x].size() - 1; i >= 0; i--) {
    r2 = r2 + r2 * solve(E[x][i]);
  }
  r1 = r1 + r2;

  /* Discount all even, odd number of odd. */
  int ev = 1;
  int odd[2] = {1, 0};
  for(int i = 0; i < E[x].size(); i++) {
    ctr res = solve(E[x][i]);
    ev = (ev + 1ll * ev * res.A[0][0]) % MOD;

    int o0 = odd[0];
    int o1 = odd[1];
    odd[0] = (o0 + 1ll * o1 * res.A[0][1]) % MOD;
    odd[1] = (o1 + 1ll * o0 * res.A[0][1]) % MOD;
  }
  r1.A[0][1] = (r1.A[0][1] - ev + MOD) % MOD;
  r1.A[1][0] = (r1.A[1][0] - ev + MOD) % MOD;
  r1.A[0][0] = (r1.A[0][0] - odd[1] + MOD) % MOD;
  r1.A[1][1] = (r1.A[1][1] - odd[1] + MOD) % MOD;

  memo[x] = r1;
  return r1;
}

int main() {
  int N;
  cin >> N;
  for(int i = 1; i < N; i++) {
    int p;
    cin >> p;
    E[p - 1].push_back(i);
  }

  memset(memo, -1, sizeof(memo));
  ctr result = solve(0);
  cout << (result.A[0][0] + result.A[0][1]) % MOD << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <ctime>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left

const ld pi = 3.14159265359;

template < typename T > T abs(T x)
{
    return x > 0 ? x : -x;
}

const ll mod = 1000000007;
const int maxn = 100005;

vector < int > g[maxn];

ll dp[maxn][2][2];

ll bpow(ll x, ll n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

void dfs(int v, int p)
{
	for (int to : g[v])
	{
		if (to == p)
			continue;
		dfs(to, v);
	}

	if (!g[v].empty())
	{
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < 2; j++)
			{
				if (i != j)
				{
					for (int iter = 0; iter < 2; iter++)
					{
						ll a[] = { i, 1 - i };

						for (int h = 0; h < g[v].size(); h++)
						{
							int to = g[v][h];
							if (iter == 1)
								to = g[v][g[v].size() - 1 - h];

							ll x = ((dp[to][0][0] * a[0]) % mod) + ((dp[to][1][0] * a[1]) % mod);
							if (x >= mod)
								x -= mod;

							ll y = ((dp[to][1][1] * a[1]) % mod) + ((dp[to][0][1] * a[0]) % mod);
							if (y >= mod)
								y -= mod;

							a[0] += x;
							if (a[0] >= mod)
								a[0] -= mod;
							a[1] += y;
							if (a[1] >= mod)
								a[1] -= mod;
						}

						dp[v][i][j] += a[j];
						if (dp[v][i][j] >= mod)
							dp[v][i][j] -= mod;
					}

					ll c = 1;
					for (int h = 0; h < g[v].size(); h++)
					{
						int to = g[v][h];

						c = (c * (1LL + dp[to][1 - i][j])) % mod;
					}

					dp[v][i][j] = (dp[v][i][j] + mod - c) % mod;
				}
				else
				{
					for (int iter = 0; iter < 2; iter++)
					{
						ll a[] = { i, 1 - i };

						for (int h = 0; h < g[v].size(); h++)
						{
							int to = g[v][h];
							if (iter == 1)
								to = g[v][g[v].size() - 1 - h];

							ll x = ((dp[to][0][0] * a[0]) % mod) + ((dp[to][1][0] * a[1]) % mod);
							if (x >= mod)
								x -= mod;

							ll y = ((dp[to][1][1] * a[1]) % mod) + ((dp[to][0][1] * a[0]) % mod);
							if (y >= mod)
								y -= mod;

							a[0] += x;
							if (a[0] >= mod)
								a[0] -= mod;
							a[1] += y;
							if (a[1] >= mod)
								a[1] -= mod;
						}

						dp[v][i][j] += a[j];
						if (dp[v][i][j] >= mod)
							dp[v][i][j] -= mod;
					}

					for (int iter = 0; iter < 1; iter++)
					{
						ll a[] = { i, 1 - i };

						for (int h = 0; h < g[v].size(); h++)
						{
							int to = g[v][h];
							if (iter == 1)
								to = g[v][g[v].size() - 1 - h];

							ll x = ((dp[to][1][0] * a[1]) % mod);

							if (x >= mod)
								x -= mod;

							ll y = ((dp[to][0][1] * a[0]) % mod);

							if (y >= mod)
								y -= mod;

							a[0] += x;
							if (a[0] >= mod)
								a[0] -= mod;

							a[1] += y;
							if (a[1] >= mod)
								a[1] -= mod;
						}

						dp[v][i][j] += (mod - a[j]);
						if (dp[v][i][j] >= mod)
							dp[v][i][j] -= mod;
					}
				}

			}
		}
	}
	else
	{
		dp[v][1][0] = dp[v][0][1] = 1;
	}
}

int main()
{
	//gen();
	//freopen("a.in", "r", stdin);
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++)
	{
		int x;
		cin >> x;
		g[x].pb(i);
	}

	dfs(1, -1);

	/*for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			for (int k = 0; k < 2; k++)
				cout << dp[i][j][k] << " ";
			cout << endl;
		}
	}*/

	cout << (dp[1][0][0] + dp[1][0][1]) % mod << endl;

	return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <ctime>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left

const ld pi = 3.14159265359;

template < typename T > T abs(T x)
{
    return x > 0 ? x : -x;
}

const ll mod = 1000000007;
const int maxn = 100005;

vector < int > g[maxn];

ll dp[maxn][2][2];

ll bpow(ll x, ll n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

void dfs(int v, int p)
{
	for (int to : g[v])
	{
		if (to == p)
			continue;
		dfs(to, v);
	}

	dp[v][0][0] = dp[v][1][1] = 1;

	if (!g[v].empty())
	{
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < 2; j++)
			{
				for (int iter = 0; iter < 2; iter++)
				{
					ll a[] = { i, 1 - i };

					for (int h = 0; h < g[v].size(); h++)
					{
						int to = g[v][h];
						if (iter == 1)
							to = g[v][g[v].size() - 1 - h];

						ll x = (dp[to][0][0] * a[0]) % mod + (dp[to][1][0] * a[1]) % mod;
						if (x >= mod)
							x -= mod;

						ll y = (dp[to][1][1] * a[1]) % mod + (dp[to][0][1] * a[0]) % mod;
						if (y >= mod)
							y -= mod;

						a[0] = x;
						a[1] = y;
					}

					dp[v][i][j] += a[j];
					if (dp[v][i][j] >= mod)
						dp[v][i][j] -= mod;
				}

				//if (v != 1)
				{
					if (i == j)
					{

						for (int h = 0; h < g[v].size(); h++)
						{
							int to = g[v][h];

							dp[v][i][j] = (dp[v][i][j] + mod - dp[to][1 - i][j]) % mod;
						}
					}
					else
					{
						ll c = 1;
						for (int h = 0; h < g[v].size(); h++)
						{
							int to = g[v][h];

							c = (c * dp[to][1 - i][j]) % mod;
						}

						dp[v][i][j] = (dp[v][i][j] - c + mod) % mod;
					}
				}
			}
		}
	}
	else
	{
		dp[v][1][0] = dp[v][0][1] = 1;
	}
}

int main()
{
	//gen();
	freopen("a.in", "r", stdin);
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++)
	{
		int x;
		cin >> x;
		g[x].pb(i);
	}

	dfs(1, -1);

	/*for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			for (int k = 0; k < 2; k++)
				cout << dp[i][j][k] << " ";
			cout << endl;
		}
	}*/

	cout << (dp[1][0][0] + dp[1][0][1] + mod - 1) % mod << endl;

	return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <ctime>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left

const ld pi = 3.14159265359;

template < typename T > T abs(T x)
{
    return x > 0 ? x : -x;
}

const ll mod = 1000000007;
const int maxn = 100005;

vector < int > g[maxn];

ll dp[maxn][2][2];

ll bpow(ll x, ll n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

void dfs(int v, int p)
{
	for (int to : g[v])
	{
		if (to == p)
			continue;
		dfs(to, v);
	}

	if (!g[v].empty())
	{
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < 2; j++)
			{
				if (i != j)
				{
					for (int iter = 0; iter < 2; iter++)
					{
						ll a[] = { i, 1 - i };

						for (int h = 0; h < g[v].size(); h++)
						{
							int to = g[v][h];
							if (iter == 1)
								to = g[v][g[v].size() - 1 - h];

							ll x = ((dp[to][0][0] * a[0]) % mod) + ((dp[to][1][0] * a[1]) % mod);
							if (x >= mod)
								x -= mod;

							ll y = ((dp[to][1][1] * a[1]) % mod) + ((dp[to][0][1] * a[0]) % mod);
							if (y >= mod)
								y -= mod;

							a[0] += x;
							if (a[0] >= mod)
								a[0] -= mod;
							a[1] += y;
							if (a[1] >= mod)
								a[1] -= mod;
						}

						dp[v][i][j] += a[j];
						if (dp[v][i][j] >= mod)
							dp[v][i][j] -= mod;
					}

					ll c = 1;
					for (int h = 0; h < g[v].size(); h++)
					{
						int to = g[v][h];

						c = (c * (1LL + dp[to][1 - i][j])) % mod;
					}

					dp[v][i][j] = (dp[v][i][j] + mod - c) % mod;
				}
				else
				{
					for (int iter = 0; iter < 2; iter++)
					{
						ll a[] = { i, 1 - i };

						for (int h = 0; h < g[v].size(); h++)
						{
							int to = g[v][h];
							if (iter == 1)
								to = g[v][g[v].size() - 1 - h];

							ll x = ((dp[to][0][0] * a[0]) % mod) + ((dp[to][1][0] * a[1]) % mod);
							if (x >= mod)
								x -= mod;

							ll y = ((dp[to][1][1] * a[1]) % mod) + ((dp[to][0][1] * a[0]) % mod);
							if (y >= mod)
								y -= mod;

							a[0] += x;
							if (a[0] >= mod)
								a[0] -= mod;
							a[1] += y;
							if (a[1] >= mod)
								a[1] -= mod;
						}

						dp[v][i][j] += a[j];
						if (dp[v][i][j] >= mod)
							dp[v][i][j] -= mod;
					}

					for (int iter = 0; iter < 1; iter++)
					{
						ll a[] = { i, 1 - i };

						for (int h = 0; h < g[v].size(); h++)
						{
							int to = g[v][h];
							if (iter == 1)
								to = g[v][g[v].size() - 1 - h];

							ll x = ((dp[to][1][0] * a[1]) % mod);

							if (x >= mod)
								x -= mod;

							ll y = ((dp[to][0][1] * a[0]) % mod);

							if (y >= mod)
								y -= mod;

							a[0] += x;
							if (a[0] >= mod)
								a[0] -= mod;

							a[1] += y;
							if (a[1] >= mod)
								a[1] -= mod;
						}

						dp[v][i][j] += (mod - a[j]);
						if (dp[v][i][j] >= mod)
							dp[v][i][j] -= mod;
					}
				}

			}
		}
	}
	else
	{
		dp[v][1][0] = dp[v][0][1] = 1;
	}
}

int main()
{
	//gen();
	//freopen("a.in", "r", stdin);
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++)
	{
		int x;
		cin >> x;
		g[x].pb(i);
	}

	dfs(1, -1);

	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			for (int k = 0; k < 2; k++)
				cout << dp[i][j][k] << " ";
			cout << endl;
		}
	}

	cout << (dp[1][0][0] + dp[1][0][1]) % mod << endl;

	return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <ctime>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left

const ld pi = 3.14159265359;

template < typename T > T abs(T x)
{
    return x > 0 ? x : -x;
}

const ll mod = 1000000007;
const int maxn = 100005;

vector < int > g[maxn];

ll dp[maxn][2][2];

ll bpow(ll x, ll n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

void dfs(int v, int p)
{
	for (int to : g[v])
	{
		if (to == p)
			continue;
		dfs(to, v);
	}

	dp[v][0][0] = dp[v][1][1] = 1;

	if (!g[v].empty())
	{
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < 2; j++)
			{
				for (int iter = 0; iter < 2; iter++)
				{
					ll a[] = { i, 1 - i };

					for (int h = 0; h < g[v].size(); h++)
					{
						int to = g[v][h];
						if (iter == 1)
							to = g[v][g[v].size() - 1 - h];

						ll x = (dp[to][0][0] * a[0]) % mod + (dp[to][1][0] * a[1]) % mod;
						if (x >= mod)
							x -= mod;

						ll y = (dp[to][1][1] * a[1]) % mod + (dp[to][0][1] * a[0]) % mod;
						if (y >= mod)
							y -= mod;

						a[0] = x;
						a[1] = y;
					}

					dp[v][i][j] += a[j];
					if (dp[v][i][j] >= mod)
						dp[v][i][j] -= mod;
				}

				//if (v != 1)
				{
					if (i == j)
					{

						for (int h = 0; h < g[v].size(); h++)
						{
							int to = g[v][h];

							dp[v][i][j] = (dp[v][i][j] + mod - dp[to][1 - i][j]) % mod;
						}
					}
					else
					{
						ll c = 1;
						for (int h = 0; h < g[v].size(); h++)
						{
							int to = g[v][h];

							c = (c * dp[to][1 - i][j]) % mod;
						}

						dp[v][i][j] = (dp[v][i][j] - c + mod) % mod;
					}
				}
			}
		}
	}
	else
	{
		dp[v][1][0] = dp[v][0][1] = 1;
	}
}

int main()
{
	//gen();
	//freopen("a.in", "r", stdin);
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++)
	{
		int x;
		cin >> x;
		g[x].pb(i);
	}

	dfs(1, -1);

	/*for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			for (int k = 0; k < 2; k++)
				cout << dp[i][j][k] << " ";
			cout << endl;
		}
	}*/

	cout << (dp[1][0][0] + dp[1][0][1] + mod - 1) % mod << endl;

	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

const int MOD = 1000000007;
int mul(int x, int y) {
    return (x*1ll*y)%MOD;
}
void add(int &x, int y) {
    x += y;
    while (x >= MOD)
        x -= MOD;
}
int sum(int  x, int y) {
    add(x, y);
    return x;
}
void sub(int &x, int y) {
    x -= y;
    while (x < 0)
        x += MOD;
}

vector<vector<int> > gr;
vector<int> kol, ans[2], d[2];
vector<int> cs, cs2;
int n;

int main() {
    scanf("%d", &n);
    gr.assign(n, vector<int>());
    for (int i = 1; i < n; ++i) {
        int v;
        scanf("%d", &v);
        gr[v-1].push_back(i);
    }
    kol.assign(n, 0);
    for (int i = n-1; i >= 0; --i) {
        kol[i] = 1;
        for (int j = 0; j < (int)gr[i].size(); ++j)
            kol[i] += kol[gr[i][j]];
    }

    ans[0].assign(n, 0);
    ans[1].assign(n, 0);
    for (int v = n-1; v >= 0; --v) {
        if (gr[v].empty()) {
            ans[0][v] = 0;
            ans[1][v] = 1;
        }
        else {
            ans[0][v] = 0;
            ans[1][v] = 0;
            for (int vvv = 0; vvv < 2; ++vvv) {
                d[0].assign(gr[v].size() + 1, 0);
                d[1].assign(gr[v].size() + 1, 0);
                d[0][0] = 1;
                for (size_t i = 0; i < gr[v].size(); ++i) {
                    add(d[0][i+1], mul(d[0][i], ans[0][gr[v][i]] + 1));
                    add(d[1][i+1], mul(d[1][i], ans[0][gr[v][i]] + 1));
                    add(d[0][i+1], mul(d[1][i], ans[1][gr[v][i]]));
                    add(d[1][i+1], mul(d[0][i], ans[1][gr[v][i]]));
                }

                add(ans[1][v], mul(d[0].back(), 1));
                add(ans[0][v], mul(d[1].back(), 1));
                reverse(gr[v].begin(), gr[v].end());
            }
            //cerr << "PROB: " << ans[0][v] << " " << ans[1][v] << "\n";
            int dv = 1;
            for (size_t i = 0; i < gr[v].size(); ++i)
                dv = mul(dv, ans[0][gr[v][i]] + 1);
            sub(ans[0][v], dv);
            d[0].assign(gr[v].size() + 1, 0);
            d[1].assign(gr[v].size() + 1, 0);
            d[0][0] = 1;
            for (size_t i = 0; i < gr[v].size(); ++i) {
                add(d[0][i+1], mul(d[0][i], 1));
                add(d[1][i+1], mul(d[1][i], 1));
                add(d[0][i+1], mul(d[1][i], ans[1][gr[v][i]]));
                add(d[1][i+1], mul(d[0][i], ans[1][gr[v][i]]));
            }
            //cerr << d[1].back() << "\n";
            sub(ans[1][v], d[1].back());

        }

        //cerr << v << " " << ans[0][v] << " " << ans[1][v] << "\n";
    }
    cout << sum(ans[0][0], ans[1][0]) << "\n";
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

const int MOD = 1000000007;
int mul(int x, int y) {
    return (x*1ll*y)%MOD;
}
void add(int &x, int y) {
    x += y;
    while (x >= MOD)
        x -= MOD;
}
int sum(int  x, int y) {
    add(x, y);
    return x;
}
void sub(int &x, int y) {
    x -= y;
    while (x < 0)
        x += MOD;
}

vector<vector<int> > gr;
vector<int> kol, ans[2], d[2];
vector<int> cs, cs2;
int n;

int main() {
    scanf("%d", &n);
    gr.assign(n, vector<int>());
    for (int i = 1; i < n; ++i) {
        int v;
        scanf("%d", &v);
        gr[v-1].push_back(i);
    }
    kol.assign(n, 0);
    for (int i = n-1; i >= 0; --i) {
        kol[i] = 1;
        for (int j = 0; j < (int)gr[i].size(); ++j)
            kol[i] += kol[gr[i][j]];
    }

    ans[0].assign(n, 0);
    ans[1].assign(n, 0);
    for (int v = n-1; v >= 0; --v) {
        if (gr[v].empty()) {
            ans[0][v] = 0;
            ans[1][v] = 1;
        }
        else {
            ans[0][v] = 0;
            ans[1][v] = 0;
            for (int vvv = 0; vvv < 2; ++vvv) {
                d[0].assign(gr[v].size() + 1, 0);
                d[1].assign(gr[v].size() + 1, 0);
                d[0][0] = 1;
                for (size_t i = 0; i < gr[v].size(); ++i) {
                    add(d[0][i+1], mul(d[0][i], ans[0][gr[v][i]] + 1));
                    add(d[1][i+1], mul(d[1][i], ans[0][gr[v][i]] + 1));
                    add(d[0][i+1], mul(d[1][i], ans[1][gr[v][i]]));
                    add(d[1][i+1], mul(d[0][i], ans[1][gr[v][i]]));
                }

                add(ans[1][v], mul(d[0].back(), 1));
                add(ans[0][v], mul(d[1].back(), 1));
                reverse(gr[v].begin(), gr[v].end());
            }
            //cerr << "PROB: " << ans[0][v] << " " << ans[1][v] << "\n";
            int dv = 1;
            for (size_t i = 0; i < gr[v].size(); ++i)
                dv = mul(dv, ans[0][gr[v][i]] + 1);
            sub(ans[1][v], dv);
            d[0].assign(gr[v].size() + 1, 0);
            d[1].assign(gr[v].size() + 1, 0);
            d[0][0] = 1;
            for (size_t i = 0; i < gr[v].size(); ++i) {
                add(d[0][i+1], mul(d[0][i], 1));
                add(d[1][i+1], mul(d[1][i], 1));
                add(d[0][i+1], mul(d[1][i], ans[1][gr[v][i]]));
                add(d[1][i+1], mul(d[0][i], ans[1][gr[v][i]]));
            }
            //cerr << d[1].back() << "\n";
            sub(ans[0][v], d[1].back());

        }

        //cerr << v << " " << ans[0][v] << " " << ans[1][v] << "\n";
    }
    cout << sum(ans[0][0], ans[1][0]) << "\n";
    return 0;
}


/**
 * Copyright (c) 2014 Authors. All rights reserved.
 *
 * FileName: D.cpp
 * Author: Beiyu Li <sysulby@gmail.com>
 * Date: 2014-11-19
 */
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)

typedef long long LL;
typedef pair<int, int> Pii;

const int inf = 0x3f3f3f3f;
const LL infLL = 0x3f3f3f3f3f3f3f3fLL;

const int maxn = 100000 + 5;
const int mod = 1000000007;

int n;
vector<int> ch[maxn];
bool vis[maxn];
int f[maxn][2];

void dp(int u)
{
        if (vis[u]) return;
        vis[u] = true;
        f[u][0] = 0; f[u][1] = 1;
        if (ch[u].empty()) return;
        int m = ch[u].size(), v;
        rep(i,m) dp(ch[u][i]);
        rep(i,m) {
                int v = ch[u][i];
                int n0 = ((LL)f[u][0] * f[v][0] + (LL)f[u][1] * f[v][1]) % mod;
                int n1 = ((LL)f[u][0] * f[v][1] + (LL)f[u][1] * f[v][0]) % mod;
                f[u][0] = (f[u][0] + n0) % mod;
                f[u][1] = (f[u][1] + n1) % mod;
        }
        f[u][0] = f[u][0] * 2 % mod;
        f[u][1] = f[u][1] * 2 % mod;
        int g[2];
        g[0] = 1;
        rep(i,m) {
                int v = ch[u][i];
                g[0] = (g[0] + (LL)g[0] * f[v][0]) % mod;
        }
        f[u][1] = (f[u][1] + mod - g[0]) % mod;
        g[0] = 1; g[1] = 0;
        rep(i,m) {
                int v = ch[u][i], t = g[0];
                g[0] = (g[0] + (LL)g[1] * f[v][1]) % mod;
                g[1] = (g[1] + (LL)t * f[v][1]) % mod;
        }
        f[u][0] = (f[u][0] + mod - g[1]) % mod;
}

int main()
{
        scanf("%d", &n);
        For(i,1,n-1) {
                int pa;
                scanf("%d", &pa);
                --pa;
                ch[pa].push_back(i);
        }
        dp(0);
        printf("%d\n", (f[0][0] + f[0][1]) % mod);

        return 0;
}


#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<string>
#include<string.h>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<map>
#include<set>
#include<iostream>
#include<sstream>
#include<cctype>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
#define drep(i,n) for(int i = n-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;

const int MX = 100005, INF = 1000010000;
const ll LINF = 1000000000000000000ll;
const double eps = 1e-10;
const int dx[] = {-1,0,1,0}, dy[] = {0,-1,0,1}; //<^>v

// Mod int
const int mod = 1000000007;
struct mint{
	ll x;
	mint():x(0){}
	mint(ll x):x(x){}
	mint operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
	mint operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
	mint operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
	mint operator+(const mint& a)const{ return mint(*this) += a;}
	mint operator-(const mint& a)const{ return mint(*this) -= a;}
	mint operator*(const mint& a)const{ return mint(*this) *= a;}
};
//

vi to[MX];
mint dp[MX][2];
mint l[2], r[2], e[2], o[2], p[2];

void dfs(int v) {
  rep(i,to[v].size()) dfs(to[v][i]);
  rep(i,2) l[i] = r[i] = e[i] = o[i] = 0;
  l[0] = 1;
  rep(i,to[v].size()) {
    int u = to[v][i];
    rep(j,2) p[j] = l[j];
    rep(j,2) l[j] = p[j]+p[j]*dp[u][0]+p[j^1]*dp[u][1];
  }
  r[0] = 1;
  drep(i,to[v].size()) {
    int u = to[v][i];
    rep(j,2) p[j] = r[j];
    rep(j,2) r[j] = p[j]+p[j]*dp[u][0]+p[j^1]*dp[u][1];
  }
  e[0] = 1;
  rep(i,to[v].size()) {
    int u = to[v][i];
    rep(j,2) p[j] = e[j];
    e[0] = p[0]+p[0]*dp[u][0];
  }
  o[0] = 1;
  rep(i,to[v].size()) {
    int u = to[v][i];
    rep(j,2) p[j] = o[j];
    o[0] = p[0]+p[1]*dp[u][1];
    o[1] = p[1]+p[0]*dp[u][1];
  }
  dp[v][1] = l[0]+r[0]-e[0];
  dp[v][0] = l[1]+r[1]-o[1];
}

int main(){
  int n;
  scanf("%d",&n);
  rrep(i,n-1) {
    int a;
    scanf("%d",&a);
    to[a-1].pb(i);
  }
  dfs(0);
  //rep(i,n) printf("%d : %I64d %I64d\n", i, dp[i][0].x, dp[i][1].x);
  cout << (dp[0][0]+dp[0][1]).x << endl;

  return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
constexpr int m = 1000000007;
int p[100000];
long long o[100000];
long long e[100000];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i < n; i++) {
        scanf("%d", p + i);
        p[i]--;
    }
    fill_n(o, n, 1);
    for(int i = n - 1; i >= 1; i--) {
        o[i] = (o[i] * 2 - 1) % m;
        long long op = o[p[i]] + o[p[i]] * e[i] + e[p[i]] * o[i];
        long long ep = e[p[i]] + e[p[i]] * e[i] + o[p[i]] * o[i];
        o[p[i]] = op % m;
        e[p[i]] = ep % m;
    }
    printf("%d\n", (int)((o[0] * 2 - 1 + e[0]) % m));
}


#include <cstdio>
#include <algorithm>
#include <cstring>

#define NDEBUG
#include <cassert>

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <array>
#include <type_traits>
#include <queue>

using namespace std;

#define int64 long long
#define repeat(x) for(auto repeat_var=0;repeat_var<x;++repeat_var)

#define for_inc(i,x) for(auto i=0; i < x;++i)
#define for_dec(i,x) for(auto i=x-1; i >= 0; --i)
#define for_inc_range(i,x,y) for (auto i=x; i<=y; ++i)
#define for_dec_range(i,x,y) for (auto i=x; i>=y; --i)

#define fill0(x) memset(x, 0, sizeof(x))
#define INT_INF 2E9L

#define ntype int
#define N_INF INT_INF

void testGen() {
  freopen("biginput1.txt", "w", stdout);
  fclose(stdout);
}

#define MAXN 100100

#define MOD 1000000007
int MODP(int64 a) {
  int r = a % MOD;
  if (r < 0) r += MOD;
  return r;
}

int n;
int parent[MAXN];
vector<int> child[MAXN];

#define EVEN 0
#define ODD 1

int f[2][MAXN]; // f[0][u], f[1][u]: color even/odd number of vertices in subtree rooted at u

int g[2][MAXN];

int h[2][2][MAXN]; // dup

void dfs(int u) {
  f[EVEN][u] = 0;
  f[ODD][u] = 1; // only color u

  if (child[u].empty()) {
    return;
  }

  for (auto &v: child[u]) {
    dfs(v);
  }
  int nChild = (int)child[u].size();

  g[EVEN][1] = MODP(1 + f[EVEN][child[u][0]]); // no color + f-child even
  g[ODD][1] = f[ODD][child[u][0]];

  for_inc_range(i, 2, nChild) {
    int v = child[u][i - 1];
    g[EVEN][i] = MODP(MODP((int64)g[EVEN][i-1] * (1 + f[EVEN][v])) + MODP((int64)g[ODD][i - 1] * f[ODD][v]));
    g[ODD][i] = MODP(MODP((int64)g[ODD][i-1] * (1 + f[EVEN][v])) + MODP((int64)g[EVEN][i - 1] * f[ODD][v]));
  }

  // Count for two-way traversal
  f[EVEN][u] = MODP(g[ODD][nChild] * 2);
  f[ODD][u] = MODP(g[EVEN][nChild] * 2);

  // Now subtract the duplicates

  h[EVEN][EVEN][1] = MODP(1 + f[EVEN][child[u][0]]);
  h[EVEN][ODD][1] = 1; // no color
  h[ODD][ODD][1] = 0;
  h[ODD][EVEN][1] = f[ODD][child[u][0]];

  for_inc_range(i, 2, nChild) {
    int v = child[u][i - 1];
    for_inc_range(curPar, 0, 1) {
      for_inc_range(remainPar, 0, 1) {
        int r = h[curPar][remainPar][i - 1]; //Not color i

        if (curPar == remainPar) {
          // color i even
          r = MODP(r + (int64)h[curPar][remainPar][i - 1] * f[EVEN][v]);
        } else {
          // color i odd
          r = MODP(r + (int64)h[1 - curPar][1 - remainPar][i - 1] * f[ODD][v]);
        }
        h[curPar][remainPar][i] = r;
      }
    }
  }

  f[EVEN][u] = MODP(f[EVEN][u] - h[ODD][EVEN][nChild]);
  f[ODD][u] = MODP(f[ODD][u] - h[EVEN][EVEN][nChild]);

}
int main() {
  //testGen();
  //freopen("input1.txt", "r", stdin);

  scanf("%d", &n);

  parent[1] = -1;
  for_inc_range(u, 2, n) {
    scanf("%d", &parent[u]);
    child[parent[u]].push_back(u);
  }

  dfs(1);

  cout << MODP(f[0][1] + f[1][1]) << endl;
  return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <ctime>
#include <numeric>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <complex>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <string>
#include <sstream>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef double ld;
typedef pair<int, int> PII;
typedef pair<short, short> PSS;
typedef pair<PII, int> PIII;
typedef pair<lng, lng> PLL;
typedef pair<ulng, ulng> PUU;
typedef pair<lng, int> PLI;
typedef pair<int, lng> PIL;
typedef pair<ld, ld> PDD;
template<class T> inline T sqr(T x) { return x * x; }
template<class T> inline string tostr(const T & x) { stringstream ss; ss << x; return ss.str(); }
inline lng parse(const string & s) { stringstream ss(s); lng x; ss >> x; return x; }
#define left asdleft
#define right asdright
#define link asdlink
#define unlink asdunlink
#define next asdnext
#define prev asdprev
#define y0 asdy0
#define y1 asdy1
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define clr(ar,val) memset(ar, val, sizeof(ar))
#define istr stringstream
#define forn(i,n) for(int i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define X first
#define Y second
#define hash asdhash
#define move asdmove
const ld EPS = 1e-9;
const int INF = 1000*1000*1000;
const char CINF = 102;
const lng LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const ld PI = 3.1415926535897932384626433832795l;
int gcd(int a,int b){return a?gcd(b%a,a):b;}
lng gcd(lng a,lng b){return a?gcd(b%a,a):b;}
lng powmod(lng a,lng p,lng m){lng r=1;while(p){if(p&1)r=r*a%m;p>>=1;a=a*a%m;}return r;}
#define FAIL { cerr<<"assertion failed on line "<<__LINE__<<endl; exit(123);}

const lng mod=INF+7;
vector<vector<int>> gr;

PLL dfs(int v){
  int n=sz(gr[v]);
  vector<PLL> ts(n);
  forn(i,n){
    ts[i]=dfs(gr[v][i]);
  }

  vector<PLL> dp1(n+1);
  vector<PLL> dp2(n+1);

  forn(qqq,2){
    dp1.assign(n+1,mp(0,0));
    dp1[0].X=1;
    forn(i,n){
      (dp1[i+1].X+=dp1[i].X*(1+ts[i].X))%=mod;
      (dp1[i+1].Y+=dp1[i].Y*(1+ts[i].X))%=mod;
      (dp1[i+1].X+=dp1[i].Y*ts[i].Y)%=mod;
      (dp1[i+1].Y+=dp1[i].X*ts[i].Y)%=mod;
    }
    reverse(all(ts));
    swap(dp1,dp2);
  }

  vector<PLL> dp3(n+1);
  dp3[0]=mp(1,0);
  forn(i,n){
    (dp3[i+1].X+=dp3[i].X*1)%=mod;
    (dp3[i+1].Y+=dp3[i].Y*1)%=mod;
    (dp3[i+1].X+=dp3[i].Y*ts[i].Y)%=mod;
    (dp3[i+1].Y+=dp3[i].X*ts[i].Y)%=mod;
  }

  vector<lng> dp4(n+1);
  dp4[0]=1;
  forn(i,n){
    (dp4[i+1]+=dp4[i]*(1+ts[i].X))%=mod;
  }

  PLL r((dp1.back().X+dp2.back().X+mod-dp4.back())%mod,(dp1.back().Y+dp2.back().Y+mod-dp3.back().Y)%mod);
  swap(r.X,r.Y);
  return r;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);

  int n;
  cin>>n;
  gr.resize(n);
  forn(i,n-1){
    int p;
    cin>>p;
    --p;
    gr[p].pb(i+1);
  }

  PLL r=dfs(0);
  cout<<(r.X+r.Y)%mod<<endl;

  return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define B 2
#define long long long
#define mod 1000000007ll
#define M 100100

struct matr {
    long a[2][2];
    matr() {
        for (int i = 0; i < 2; ++i)
            for (int j = 0; j < 2; ++j)
                a[i][j] = 0;
    }

    matr operator * (const matr &x) const {
        matr ans;
        for (int i = 0; i < 2; ++i)
            for (int j = 0; j < 2; ++j)
                for (int k = 0; k < 2; ++k)
                    ans.a[i][k] = (ans.a[i][k] + a[i][j] * x.a[j][k]) % mod;
        return ans;
    }

    matr operator + (const matr &x) const {
        matr ans;
        for (int i = 0; i < 2; ++i)
            for (int j = 0; j < 2; ++j)
                ans.a[i][j] = (a[i][j] + x.a[i][j]) % mod;
        return ans;
    }

    matr operator - (const matr &x) const {
        matr ans;
        for (int i = 0; i < 2; ++i)
            for (int j = 0; j < 2; ++j)
                ans.a[i][j] = (a[i][j] - x.a[i][j]) % mod;
        return ans;
    }

    matr operator % (const matr &x) const {
        matr ans;
        for (int i = 0; i < 2; ++i)
            for (int j = 0; j < 2; ++j)
                ans.a[j][i] = (a[i][j] * x.a[j][i]) % mod;
        return ans;
    }

    void print() {
        for (int i = 0; i < 2; ++i, cout << "\n")
            for (int j = 0; j < 2; ++j, cout << " ")
                cout << a[i][j];
    }
} ini, zero, d[M];

void initiate() {
    ini.a[0][1] = ini.a[1][0] = 1;
}

int n;
vector<int> g[M];

void read() {
    cin >> n;
    for (int i = 2, x; i <= n; ++i) {
        cin >> x;
        g[x].push_back(i);
    }
    for (int i = 1; i < n; ++i) {
        sort(g[i].begin(), g[i].end());
    }
}

matr ch(const matr &x) {
    matr ans;
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < 2; ++j)
            ans.a[1 - i][j] = x.a[i][j];
    return ans;
}

void dfs(int v) {
    d[v] = zero;

    for (int & to : g[v])
        dfs(to);

    matr x;

    for (int i = 0; i < (int) g[v].size(); ++i) {
        int to = g[v][i];
        x = x + (x * d[to]) + ch(d[to]);
    }

    matr y;

    for (int i = (int) g[v].size() - 1; i >= 0; --i) {
        int to = g[v][i];
        y = y + (y * d[to]) + ch(d[to]);
    }

    matr minus;

    //(x + y).print();

    matr z;

    for (int i = 0; i < 2; ++i) {
        z = zero;

        for (int k = 0; k < (int) g[v].size(); ++k) {
            int to = g[v][k];

            matr nz = z + (z % d[to]);
            for (int j = 0; j < 2; ++j)
                nz.a[i][j] += d[to].a[i][j];
            z = nz;
        }

        //for (int j = 0; j < 2; ++j)
            for (int k = 0; k < 2; ++k) {
                minus.a[i][k] += z.a[i][k];
            }
    }

    //minus.print();

    d[v] = (x + y) - ch(minus) + ini;

    //d[v].print();
}

int main() {
    ios_base::sync_with_stdio(false);

    initiate();
    read();
    dfs(1);

    long ans = 0;
    for (int j = 0; j < 2; ++j)
        ans = (ans + d[1].a[0][j]) % mod;

    if (ans < 0)
        ans += mod;

    cout << ans << "\n";

    return 0;
}


#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <cmath>
#include <complex>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>
#include <valarray>
#include <list>
#include <cstring>

using namespace std;

typedef long long ll;

const int MN = 100100;
const ll MD = 1e9+7;

int n;
vector<int> g[MN];
ll res[MN][2];
void solve(int p) {
    for (int d: g[p]) {
        solve(d);
    }
    ll l[2] = {};
    l[0] = 1;
    for (int d: g[p]) {
        auto &r = res[d];
        int ll[2];
        ll[0] = r[0]*l[0]%MD + r[1]*l[1]%MD;
        ll[1] = r[0]*l[1]%MD + r[1]*l[0]%MD;
        l[0] = ll[0]%MD;
        l[1] = ll[1]%MD;
    }
    ll k = 1;
    for (int d: g[p]) {
        k *= res[d][0];
        k %= MD;
    }
    ll m[2] = {};
    m[0] = 1;
    for (int d: g[p]) {
        ll mm[2];
        auto &r = res[d];
        mm[0] = m[0] + m[1]*r[1]%MD;
        mm[1] = m[1] + m[0]*r[1]%MD;
        m[0] = mm[0]%MD;
        m[1] = mm[1]%MD;
    }
    res[p][0] = ((l[1]*2+1 - m[1])%MD + MD) % MD;
    res[p][1] = ((l[0]*2 - k)%MD + MD) % MD;
}

int main() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        int d;
        cin >> d; d--;
        g[d].push_back(i);
    }
    solve(0);
    cout << (res[0][0]+res[0][1]-1+MD)%MD << endl;
}


#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <cmath>
#include <complex>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>
#include <valarray>
#include <list>
#include <cstring>

using namespace std;

typedef long long ll;

const int MN = 100100;
const ll MD = 1e9+7;

int n;
vector<int> g[MN];
ll res[MN][2];
void solve(int p) {
    for (int d: g[p]) {
        solve(d);
    }
    int l[2] = {};
    l[0] = 1;
    for (int d: g[p]) {
        auto &r = res[d];
        int ll[2];
        ll[0] = r[0]*l[0] + r[1]*l[1];
        ll[1] = r[0]*l[1] + r[1]*l[0];
        l[0] = ll[0];
        l[1] = ll[1];
    }
    int k = 1;
    for (int d: g[p]) {
        k *= res[d][0];
    }
    int m[2] = {};
    m[0] = 1;
    for (int d: g[p]) {
        int mm[2];
        auto &r = res[d];
        mm[0] = m[0] + m[1]*r[1];
        mm[1] = m[1] + m[0]*r[1];
        m[0] = mm[0];
        m[1] = mm[1];
    }
    res[p][0] = l[1]*2+1 - m[1];
    res[p][1] = l[0]*2 - k;
}

int main() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        int d;
        cin >> d; d--;
        g[d].push_back(i);
    }
    solve(0);
    cout << res[0][0]+res[0][1]-1 << endl;
}


#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <cmath>
#include <complex>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>
#include <valarray>
#include <list>
#include <cstring>

using namespace std;

typedef long long ll;

const int MN = 100100;
const ll MD = 1e9+7;

int n;
vector<int> g[MN];
ll res[MN][2];
void solve(int p) {
    for (int d: g[p]) {
        solve(d);
    }
    ll l[2] = {};
    l[0] = 1;
    for (int d: g[p]) {
        auto &r = res[d];
        int ll[2];
        ll[0] = r[0]*l[0]%MD + r[1]*l[1]%MD;
        ll[1] = r[0]*l[1]%MD + r[1]*l[0]%MD;
        l[0] = ll[0]%MD;
        l[1] = ll[1]%MD;
    }
    ll k = 1;
    for (int d: g[p]) {
        k *= res[d][0];
        k %= MD;
    }
    ll m[2] = {};
    m[0] = 1;
    for (int d: g[p]) {
        ll mm[2];
        auto &r = res[d];
        mm[0] = m[0] + m[1]*r[1]%MD;
        mm[1] = m[1] + m[0]*r[1]%MD;
        m[0] = mm[0]%MD;
        m[1] = mm[1]%MD;
    }
    res[p][0] = l[1]*2+1 - m[1];
    res[p][1] = l[0]*2 - k;
}

int main() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        int d;
        cin >> d; d--;
        g[d].push_back(i);
    }
    solve(0);
    cout << (res[0][0]+res[0][1]-1+MD)%MD << endl;
}


#include <cstdio>
#include <iostream>
#include <map>
#include <algorithm>
#include <set>
#include <vector>
#include <bitset>
#include <cstdlib>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

int parent[N];
vector<int> child[N];
bitset<100007> vis;
int dp[N][2];

int subM(ll a, ll b)
{
  a -= b;

  if (a < 0)
    {
      return a + MOD;
    }

  return a >= MOD ? a - MOD : a;
}

int addM(ll a, ll b)
{
  a += b;

  return a >= MOD ? a - MOD : a;
}

int mulM(ll a, ll b)
{
  a *= b;

  return a >= MOD ? a % MOD : a;
}

void callList(const vector<int>& childList, int ans[2])
{
  int sum[2] = {0, 1};

  for (auto i: childList)
    {
      int tmpSum[2] = {0};

      tmpSum[0] = addM(mulM(sum[0], dp[i][0]), mulM(sum[1], dp[i][1]));
      tmpSum[1] = addM(mulM(sum[0], dp[i][1]), mulM(sum[1], dp[i][0]));

      sum[0] = addM(sum[0], tmpSum[0]);
      sum[1] = addM(sum[1], tmpSum[1]);
    }

  ans[0] = addM(ans[0], sum[0]);
  ans[1] = addM(ans[1], sum[1]);
}

void call(int v)
{
  if (vis.test(v))
    {
      return;
    }

  vis.set(v, true);

  vector<int> tmpList;
  for (auto i: child[v])
    {
      tmpList.push_back(i);
      call(i);
    }

  callList(tmpList, dp[v]);
  reverse(tmpList.begin(), tmpList.end());
  callList(tmpList, dp[v]);

  int sub[2][2] = {{0, 0}, {1, 1}};

  for (auto i: tmpList)
    {
      int tmpSub[2][2] = {0};

      for (int j = 0; j < 2; ++j)
	{
	  for (int k = 0; k < 2; ++k)
	    {
	      tmpSub[1 ^ j][k ^ 1] = addM(tmpSub[1 ^ j][1 ^ k],
				  mulM(sub[k][j], dp[i][1 ^ k ^ j]));
	    }
	}

      for (int j = 0; j < 2; ++j)
	{
	  for (int k = 0; k < 2; ++k)
	    {
	      sub[j][k] = addM(sub[j][k], tmpSub[j][k]);
	    }
	}
    }

  dp[v][0] = subM(dp[v][0], sub[0][0]);
  dp[v][1] = subM(dp[v][1], sub[1][0]);
}

int main()
{
  int n;
  scanf("%d", &n);

  for (int i = 1; i < n; ++i)
    {
      int p;
      scanf("%d", &p);

      parent[i] = p - 1;
      child[p - 1].push_back(i);
    }

  call(0);

  printf("%d", addM(dp[0][0], dp[0][1]));

  return 0;
}


//#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#define mp make_pair
#define pb push_back

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

using namespace std;

#define TASKNAME "D"

#ifdef LOCAL
static struct __timestamper {
    string what;
    __timestamper(const char* what) : what(what){};
    __timestamper(const string& what) : what(what){};
    ~__timestamper(){
        TIMESTAMPf("%s", what.data());
    }
} __TIMESTAMPER("end");
#else
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;

void add(int& a, int b) {
    if ((a += b) >= MOD) a -= MOD;
}

int mul(int a, int b) {
    return (a * ll(b)) % MOD;
}

const int MAXN = 110000;

int dp[MAXN][2];
vector<int> g[MAXN];

void dfs(int v) {
    int dp2[8];
    memset(dp2, 0, sizeof(dp2));
    dp2[0] = 1;
    for (int i = 0; i < (int)g[v].size(); i++) {
        int u = g[v][i];
        dfs(u);
        int dp3[8];
        memset(dp3, 0, sizeof(dp3));
        for (int j = 0; j < 8; j++) {
            add(dp3[j], dp2[j]);
            add(dp3[j | 1], mul(dp2[j], dp[u][0]));
            add(dp3[(j | 2) ^ 4], mul(dp2[j], dp[u][1]));
        }
        memcpy(dp2, dp3, sizeof(dp3));
    }
    for (int i = 0; i < 8; i++) {
        int parity = i >> 2;
        add(dp[v][parity ^ 1], dp2[i]);
        if (i & (1<<!parity)) add(dp[v][parity ^ 1], dp2[i]);
    }
}

int main(){
  #ifdef LOCAL
    assert(freopen(TASKNAME".in","r",stdin));
    assert(freopen(TASKNAME".out","w",stdout));
  #endif
    int n;
    scanf("%d",&n);
    for (int i = 1; i < n; i++){
        int p;
        scanf("%d",&p);
        --p;
        g[p].pb(i);
    }

    dfs(0);
    int ans = 0;
    add(ans, dp[0][0]);
    add(ans, dp[0][1]);
    printf("%d\n", ans);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF int(1e9+1)
#define INFL ll(2e18+INF)
#define sz(x) ((int) (x).size())
typedef long long ll;
typedef long double ld;
typedef complex <ld> point;
void solve();

#define NAME "d"
#define LOCAL_INPUT NAME ".in"
//~ #define LOCAL_OUTPUT NAME ".out"
//~ #define INPUT NAME ".in"
//~ #define OUTPUT NAME ".out"

int main() {
    srand(time(0));
    cout.setf(ios::fixed);
    cout.precision(10);
    #ifdef _GEANY
        clock_t start = clock();
        #ifdef LOCAL_INPUT
            assert(freopen(LOCAL_INPUT, "r", stdin));
        #endif
        #ifdef LOCAL_OUTPUT
            assert(freopen(LOCAL_OUTPUT, "w", stdout));
        #endif
    #else
        #ifdef INPUT
            assert(freopen(INPUT, "r", stdin));
        #endif
        #ifdef OUTPUT
            assert(freopen(OUTPUT, "w", stdout));
        #endif
    #endif
    int tn = 1;
    for (int i = 0; i < tn; ++i)
        solve();
    #ifdef _GEANY
        fprintf(stderr, "Time: %.3fs\n", double(clock() - start) / CLOCKS_PER_SEC);
    #endif
}

vector <int> g[100001];

const ll mod = 1000000007;

inline void add(ll &a, ll b) {
    a += b;
    a %= mod;
}

pair <ll, ll> dfs(int u) {
    sort(g[u].begin(), g[u].end());
    ll res[2][2][2];
    memset(res, 0, sizeof(res));
    res[1][0][0] = 1;
    for (int i = 0; i < sz(g[u]); ++i) {
        pair <ll, ll> c = dfs(g[u][i]);
        ll even = c.first;
        ll odd = c.second;
        //~ cerr << "son " << even << ' ' << odd << '\n';
        ll cres[2][2][2];
        for (int sum = 0; sum < 2; ++sum)
            for (int was_odd = 0; was_odd < 2; ++was_odd)
                for (int was_even = 0; was_even < 2; ++was_even)
                    cres[sum][was_odd][was_even] = res[sum][was_odd][was_even];
        //~ cerr << "was even " << res[0][0][1] + res[1][0][1] << '\n';
        //~ cerr << "was odd " << res[0][1][0] + res[1][1][0] << '\n';
        for (int sum = 0; sum < 2; ++sum)
            for (int was_odd = 0; was_odd < 2; ++was_odd)
                for (int was_even = 0; was_even < 2; ++was_even) {
                    add(res[sum ^ 1][1][was_even], odd * cres[sum][was_odd][was_even]);
                    add(res[sum][was_odd][1], even * cres[sum][was_odd][was_even]);
                }
    }
    for (int sum = 0; sum < 2; ++sum)
        for (int was_odd = 0; was_odd < 2; ++was_odd)
            for (int was_even = 0; was_even < 2; ++was_even) {
                if ((was_odd && sum == 1) || (was_even && sum == 0))
                    add(res[sum][was_odd][was_even], res[sum][was_odd][was_even]);
            }
    ll odd = 0, even = 0;
    for (int was_odd = 0; was_odd < 2; ++was_odd)
        for (int was_even = 0; was_even < 2; ++was_even) {
            add(odd, res[1][was_odd][was_even]);
            add(even, res[0][was_odd][was_even]);
        }
    return make_pair(even, odd);
}

void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int p;
        cin >> p;
        --p;
        g[p].push_back(i + 1);
    }
    pair <ll, ll> res = dfs(0);
    cout << (res.first + res.second) % mod << '\n';
}


#include <bits/stdc++.h>
using namespace std;
#define INF int(1e9+1)
#define INFL ll(2e18+INF)
#define sz(x) ((int) (x).size())
typedef long long ll;
typedef long double ld;
typedef complex <ld> point;
void solve();

#define NAME "d"
#define LOCAL_INPUT NAME ".in"
//~ #define LOCAL_OUTPUT NAME ".out"
//~ #define INPUT NAME ".in"
//~ #define OUTPUT NAME ".out"

int main() {
	srand(time(0));
	cout.setf(ios::fixed);
	cout.precision(10);
	#ifdef _GEANY
		clock_t start = clock();
		#ifdef LOCAL_INPUT
			assert(freopen(LOCAL_INPUT, "r", stdin));
		#endif
		#ifdef LOCAL_OUTPUT
			assert(freopen(LOCAL_OUTPUT, "w", stdout));
		#endif
	#else
		#ifdef INPUT
			assert(freopen(INPUT, "r", stdin));
		#endif
		#ifdef OUTPUT
			assert(freopen(OUTPUT, "w", stdout));
		#endif
	#endif
	int tn = 1;
	for (int i = 0; i < tn; ++i)
		solve();
	#ifdef _GEANY
		fprintf(stderr, "Time: %.3fs\n", double(clock() - start) / CLOCKS_PER_SEC);
	#endif
}

vector <int> g[100001];

const int mod = 1000000007;

pair <ll, ll> dfs(int u) {
	sort(g[u].begin(), g[u].end());
	ll res[2] = {0, 1};
	for (int i = 0; i < sz(g[u]); ++i) {
		pair <ll, ll> c = dfs(g[u][i]);
		ll odd = res[0] * c.second + res[1] * c.first + res[1];
		ll even = res[1] * c.second + res[0] * c.first + res[0];
		res[0] = even % mod;
		res[1] = odd % mod;
	}
	if (res[0] > 0) {
		res[0] = (res[0] * 2 - 1);
		res[0] %= mod;
	}
	//~ cerr << u + 1 << ' ' << res[0] << ' ' << res[1] << '\n';
	return make_pair(res[0], res[1]);
}

void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		int p;
		cin >> p;
		--p;
		g[p].push_back(i + 1);
	}
	pair <ll, ll> res = dfs(0);
	cout << res.first + res.second << '\n';
}


#include <bits/stdc++.h>
using namespace std;
#define INF int(1e9+1)
#define INFL ll(2e18+INF)
#define sz(x) ((int) (x).size())
typedef long long ll;
typedef long double ld;
typedef complex <ld> point;
void solve();

#define NAME "d"
#define LOCAL_INPUT NAME ".in"
//~ #define LOCAL_OUTPUT NAME ".out"
//~ #define INPUT NAME ".in"
//~ #define OUTPUT NAME ".out"

int main() {
	srand(time(0));
	cout.setf(ios::fixed);
	cout.precision(10);
	#ifdef _GEANY
		clock_t start = clock();
		#ifdef LOCAL_INPUT
			assert(freopen(LOCAL_INPUT, "r", stdin));
		#endif
		#ifdef LOCAL_OUTPUT
			assert(freopen(LOCAL_OUTPUT, "w", stdout));
		#endif
	#else
		#ifdef INPUT
			assert(freopen(INPUT, "r", stdin));
		#endif
		#ifdef OUTPUT
			assert(freopen(OUTPUT, "w", stdout));
		#endif
	#endif
	int tn = 1;
	for (int i = 0; i < tn; ++i)
		solve();
	#ifdef _GEANY
		fprintf(stderr, "Time: %.3fs\n", double(clock() - start) / CLOCKS_PER_SEC);
	#endif
}

vector <int> g[100001];

const ll mod = 1000000007;

inline void add(ll &a, ll b) {
	a += b;
	a %= mod;
}

pair <ll, ll> dfs(int u) {
	sort(g[u].begin(), g[u].end());
	ll res[2][2][2];
	memset(res, 0, sizeof(res));
	res[1][0][0] = 1;
	for (int i = 0; i < sz(g[u]); ++i) {
		pair <ll, ll> c = dfs(g[u][i]);
		ll even = c.first;
		ll odd = c.second;
		//~ cerr << "son " << even << ' ' << odd << '\n';
		ll cres[2][2][2];
		for (int sum = 0; sum < 2; ++sum)
			for (int was_odd = 0; was_odd < 2; ++was_odd)
				for (int was_even = 0; was_even < 2; ++was_even)
					cres[sum][was_odd][was_even] = res[sum][was_odd][was_even];
		//~ cerr << "was even " << res[0][0][1] + res[1][0][1] << '\n';
		//~ cerr << "was odd " << res[0][1][0] + res[1][1][0] << '\n';
		for (int sum = 0; sum < 2; ++sum)
			for (int was_odd = 0; was_odd < 2; ++was_odd)
				for (int was_even = 0; was_even < 2; ++was_even) {
					add(res[sum ^ 1][1][was_even], odd * cres[sum][was_odd][was_even]);
					add(res[sum][was_odd][1], even * cres[sum][was_odd][was_even]);
				}
	}
	for (int sum = 0; sum < 2; ++sum)
		for (int was_odd = 0; was_odd < 2; ++was_odd)
			for (int was_even = 0; was_even < 2; ++was_even) {
				if ((was_odd && sum == 1) || (was_even && sum == 0))
					add(res[sum][was_odd][was_even], res[sum][was_odd][was_even]);
			}
	ll odd = 0, even = 0;
	for (int was_odd = 0; was_odd < 2; ++was_odd)
		for (int was_even = 0; was_even < 2; ++was_even) {
			add(odd, res[1][was_odd][was_even]);
			add(even, res[0][was_odd][was_even]);
		}
	return make_pair(even, odd);
}

void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		int p;
		cin >> p;
		--p;
		g[p].push_back(i + 1);
	}
	pair <ll, ll> res = dfs(0);
	cout << res.first + res.second << '\n';
}


#include <bits/stdc++.h>
using namespace std;
#define INF int(1e9+1)
#define INFL ll(2e18+INF)
#define sz(x) ((int) (x).size())
typedef long long ll;
typedef long double ld;
typedef complex <ld> point;
void solve();

#define NAME "d"
#define LOCAL_INPUT NAME ".in"
//~ #define LOCAL_OUTPUT NAME ".out"
//~ #define INPUT NAME ".in"
//~ #define OUTPUT NAME ".out"

int main() {
	srand(time(0));
	cout.setf(ios::fixed);
	cout.precision(10);
	#ifdef _GEANY
		clock_t start = clock();
		#ifdef LOCAL_INPUT
			assert(freopen(LOCAL_INPUT, "r", stdin));
		#endif
		#ifdef LOCAL_OUTPUT
			assert(freopen(LOCAL_OUTPUT, "w", stdout));
		#endif
	#else
		#ifdef INPUT
			assert(freopen(INPUT, "r", stdin));
		#endif
		#ifdef OUTPUT
			assert(freopen(OUTPUT, "w", stdout));
		#endif
	#endif
	int tn = 1;
	for (int i = 0; i < tn; ++i)
		solve();
	#ifdef _GEANY
		fprintf(stderr, "Time: %.3fs\n", double(clock() - start) / CLOCKS_PER_SEC);
	#endif
}

vector <int> g[100001];

const ll mod = 1000000007;

pair <ll, ll> dfs(int u) {
	sort(g[u].begin(), g[u].end());
	ll res_even = 0;
	ll res_odd = 1;
	for (int i = 0; i < sz(g[u]); ++i) {
		pair <ll, ll> c = dfs(g[u][i]);
		ll c_even = c.first;
		ll c_odd = c.second;
		ll odd = res_even * c_odd + res_odd * c_even + res_odd;
		ll even = res_odd * c_odd + res_even * c_even + res_even;
		res_even = even % mod;
		res_odd = odd % mod;
	}
	res_odd += res_odd - 1;
	res_odd %= mod;
	if (res_odd < 0)
		res_odd += mod;
	return make_pair(res_even, res_odd);
}

void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		int p;
		cin >> p;
		--p;
		g[p].push_back(i + 1);
	}
	pair <ll, ll> res = dfs(0);
	cout << res.first + res.second << '\n';
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <vector>
#include <ctime>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, b, e) for (int i = (int)(b); i <= (int)(e); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
const int inf = 1e9+100500;
const int maxn = 100500;
const int mod = 1000000007;
int add(int x, int y) { return (x+y)%mod; }
void madd(int &x, int y) { x = add(x, y); }
int mul(int x, int y) { return (i64)x*y%mod; }

int n;
int d[maxn][2];
vi e[maxn];

void scan() {
    scanf("%d", &n);
    forn(i, n-1) {
        int p;
        scanf("%d", &p);
        e[p-1].pb(i+1);
    }
    forn(i, n) sort(all(e[i]));
}

void dfs(int v) {
    int dg = e[v].size();
    vector<vi> g(dg+1, vi(2, 0));
    g[0][0] = 1;
    g[0][1] = 0;

    forn(i, dg) {
        int to = e[v][i];
        dfs(to);
        madd(g[i+1][0], g[i][0]);
        madd(g[i+1][1], g[i][1]);
        forn(t, 2) {
            madd(g[i+1][ t], mul(g[i][0], d[to][t]));
            madd(g[i+1][!t], mul(g[i][1], d[to][t]));
        }
    }
    d[v][1] = ((i64)g[dg][0] * 2 - 1) % mod;
    d[v][0] = g[dg][1];
//     cout << "v = " << v << endl;
//     cout << d[v][0] << " " << d[v][1] << endl;
}

int main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif

    scan();
    dfs(0);
    printf("%d\n", add(d[0][0], d[0][1]));

#ifdef HOME
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <vector>
#include <ctime>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, b, e) for (int i = (int)(b); i <= (int)(e); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
const int inf = 1e9+100500;
const int maxn = 100500;
const int mod = 1000000007;
int add(int x, int y) { return (x+y)%mod; }
void madd(int &x, int y) { x = add(x, y); }
int mul(int x, int y) { return (i64)x*y%mod; }

int n;
int d[maxn][2];
vi e[maxn];

void scan() {
    scanf("%d", &n);
    forn(i, n-1) {
        int p;
        scanf("%d", &p);
        e[p-1].pb(i+1);
    }
    forn(i, n) sort(all(e[i]));
}

int g[maxn][2];

void dfs(int v) {
    int dg = e[v].size();
    forn(i, dg) dfs(e[v][i]);

    // count sim
    forn(TG, 2) {
        forn(i, dg+1) forn(j, 2) g[i][j] = 0;
        g[0][0] = 1;

        forn(i, dg) {
            int to = e[v][i];
            forn(r, 2) {
                madd(g[i+1][r], g[i][r]);
                madd(g[i+1][r^TG], mul(g[i][r], d[to][!TG]));
            }
        }
        d[v][TG] = g[dg][TG];
    }

    // non-sim
    forn(i, dg+1) forn(j, 2) g[i][j] = 0;
    g[0][0] = 1;

    forn(i, dg) {
        int to = e[v][i];
        forn(r, 2) {
            madd(g[i+1][r], g[i][r]);
            forn(t, 2) {
                madd(g[i+1][r^t], mul(g[i][r], d[to][t]));
            }
        }
    }
//     cout << "v = " << v << endl;
//     cout << "sim: " << d[v][0] << " " << d[v][1] << endl;
//     cout << "total: " << g[dg][0] << " " << g[dg][1] << endl;
    forn(i, 2) {
        d[v][i] = ((i64)g[dg][i] * 2 - d[v][i] + mod) % mod;
    }
//     cout << "all: " << d[v][0] << " " << d[v][1] << endl;
}

int main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif

    scan();
    dfs(0);
    printf("%d\n", add(d[0][0], d[0][1]));

#ifdef HOME
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <vector>
#include <ctime>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, b, e) for (int i = (int)(b); i <= (int)(e); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
const int inf = 1e9+100500;
const int maxn = 100500;
const int mod = 1000000007;
int add(int x, int y) { return (x+y)%mod; }
void madd(int &x, int y) { x = add(x, y); }
int mul(int x, int y) { return (i64)x*y%mod; }

int n;
int d[maxn][2];
vi e[maxn];

void scan() {
    scanf("%d", &n);
    forn(i, n-1) {
        int p;
        scanf("%d", &p);
        e[p-1].pb(i+1);
    }
    forn(i, n) sort(all(e[i]));
}

void dfs(int v) {
    int dg = e[v].size();
    vector<vi> g(dg+1, vi(2, 0));
    g[0][0] = 1;
    g[0][1] = 0;

    forn(i, dg) {
        int to = e[v][i];
        dfs(to);
        madd(g[i+1][0], g[i][0]);
        madd(g[i+1][1], g[i][1]);
        forn(t, 2) {
            madd(g[i+1][ 1], mul(g[i][0], d[to][t]));
            madd(g[i+1][ 0], mul(g[i][1], d[to][t]));
        }
    }
    d[v][1] = ((i64)g[dg][0] * 2 - 1) % mod;
    d[v][0] = g[dg][1];
//     cout << "v = " << v << endl;
//     cout << d[v][0] << " " << d[v][1] << endl;
}

int main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif

    scan();
    dfs(0);
    printf("%d\n", add(d[0][0], d[0][1]));

#ifdef HOME
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <vector>
#include <ctime>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, b, e) for (int i = (int)(b); i <= (int)(e); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
const int inf = 1e9+100500;
const int maxn = 100500;
const int mod = 1000000007;
int add(int x, int y) { return (x+y)%mod; }
void madd(int &x, int y) { x = add(x, y); }
int mul(int x, int y) { return (i64)x*y%mod; }

int n;
int d[maxn][2];
vi e[maxn];

void scan() {
    scanf("%d", &n);
    forn(i, n-1) {
        int p;
        scanf("%d", &p);
        e[p-1].pb(i+1);
    }
    forn(i, n) sort(all(e[i]));
}

int g[maxn][2];

void dfs(int v) {
    int dg = e[v].size();
    forn(i, dg) dfs(e[v][i]);

    // count sim
    forn(TG, 2) {
        forn(i, dg+1) forn(j, 2) g[i][j] = 0;
        g[0][0] = 1;

        forn(i, dg) {
            int to = e[v][i];
            forn(r, 2) {
                madd(g[i+1][r], g[i][r]);
                madd(g[i+1][r^TG], mul(g[i][r], d[to][TG]));
            }
        }
        d[v][!TG] = g[dg][TG];
    }

    // non-sim
    forn(i, dg+1) forn(j, 2) g[i][j] = 0;
    g[0][0] = 1;

    forn(i, dg) {
        int to = e[v][i];
        forn(r, 2) {
            madd(g[i+1][r], g[i][r]);
            forn(t, 2) {
                madd(g[i+1][r^t], mul(g[i][r], d[to][t]));
            }
        }
    }
//     cout << "v = " << v << endl;
//     cout << "sim: " << d[v][0] << " " << d[v][1] << endl;
//     cout << "total: " << g[dg][1] << " " << g[dg][0] << endl;
    forn(i, 2) {
        d[v][i] = ((i64)g[dg][!i] * 2 - d[v][i] + mod) % mod;
    }
//     cout << "all: " << d[v][0] << " " << d[v][1] << endl;
}

int main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif

    scan();
    dfs(0);
    printf("%d\n", add(d[0][0], d[0][1]));

#ifdef HOME
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long, long long> pll; typedef vector<pair<long long, long long> > vpll;
typedef vector<string> vs; typedef long double ld;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt(): x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
typedef ModInt<1000000007> mint;

vector<vi> g;
vector<int> subtreesize;

int dfs(int i) {
	int r = 1;
	each(j, g[i])
		r += dfs(*j);
	return subtreesize[i] = r;
}

vector<vi> stateidx;
vi t_ord;
int nstates = 0;

void tree_getstateindices(int root) {
	int n = g.size();
	stateidx.assign(n, vi());
	t_ord.clear();
	nstates = 0;

	vector<int> stk; stk.push_back(root);
	while(!stk.empty()) {
		int i = stk.back(); stk.pop_back();
		t_ord.push_back(i);
		stateidx[i].assign(g[i].size() + 1, -1);
		rep(j, g[i].size()) {
			int c = g[i][j];
			stk.push_back(c);
			stateidx[i][j] = nstates ++;
		}
		stateidx[i][g[i].size()] = nstates ++;
	}
}

inline int getstateindex(int i, int j) {
	int s = stateidx[i][j];
	return s != -1 ? s : stateidx[i][j+1];
}

vector<mint> memo[16];
mint rec3(int i, int j, int left, int right, bool notperm, int siz) {
	int s = stateidx[i][j];
	mint &r = memo[left * 8 + right * 4 + notperm * 2 + siz][s];
	if(r.get() != -1) return r;
	if(j == (g[i].size() + 1) / 2)
		return r = siz == 1 ? (notperm ? 2 : 1) : 0;
	r = 0;
	int c1 = g[i][j], c2 = g[i][g[i].size()-1-j];
	rep(le, 2) rep(ri, 2) rep(leb, 2) rep(rib, 2) {
		if(c1 == c2 && (le != ri || leb != rib)) continue;
		if(leb == 0 && le == 1) continue;
		if(rib == 0 && ri == 1) continue;
		mint x = 1;
		if(c1 != c2) {
			x *= rec3(i, j+1, left ^ le, right ^ ri,
				notperm || ( left != (siz ^ 1 ^ le ^ right) && leb == 1)
				        || (right != (siz ^ 1 ^ ri ^  left) && rib == 1),
				siz ^ le ^ ri);
		}else {
			x *= rec3(i, j+1, left ^ le, right ^ ri, notperm, siz ^ le ^ ri);
		}
		if(leb == 1)
			x *= rec3(c1, 0, 0, 0, false, le);
		if(rib == 1 && c1 != c2)
			x *= rec3(c2, 0, 0, 0, false, ri);
		r += x;
	}
	return r;
}

int main() {
	int n;
	scanf("%d", &n);
	g.assign(n, vi());
	reu(i, 1, n) {
		int p;
		scanf("%d", &p), -- p;
		g[p].push_back(i);
	}
	subtreesize.assign(n, 0);
	dfs(0);
	tree_getstateindices(0);
	mint initt; initt.x = -1;
	rep(k, 16)
		memo[k].assign(nstates, initt);
	mint ans = 0;
	ans += rec3(0, 0, 0, 0, false, 0);
	ans += rec3(0, 0, 0, 0, false, 1);
	printf("%d\n", ans.get());
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long, long long> pll; typedef vector<pair<long long, long long> > vpll;
typedef vector<string> vs; typedef long double ld;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt(): x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
typedef ModInt<1000000007> mint;

vector<vi> g;
vector<int> subtreesize;

int dfs(int i) {
	int r = 1;
	each(j, g[i])
		r += dfs(*j);
	return subtreesize[i] = r;
}

vector<vi> stateidx;
vi t_ord;
int nstates = 0;

void tree_getstateindices(int root) {
	int n = g.size();
	stateidx.assign(n, vi());
	t_ord.clear();
	nstates = 0;

	vector<int> stk; stk.push_back(root);
	while(!stk.empty()) {
		int i = stk.back(); stk.pop_back();
		t_ord.push_back(i);
		stateidx[i].assign(g[i].size() + 1, -1);
		rep(j, g[i].size()) {
			int c = g[i][j];
			stk.push_back(c);
			stateidx[i][j] = nstates ++;
		}
		stateidx[i][g[i].size()] = nstates ++;
	}
}

inline int getstateindex(int i, int j) {
	int s = stateidx[i][j];
	return s != -1 ? s : stateidx[i][j+1];
}

vector<mint> memo[16];
mint rec3(int i, int j, int left, int right, bool notperm, int siz) {
	int s = stateidx[i][j];
	mint &r = memo[left * 8 + right * 4 + notperm * 2 + siz][s];
	if(r.get() != -1) return r;
	if(j == (g[i].size() + 1) / 2)
		return r = siz == 1 ? (notperm ? 2 : 1) : 0;
	r = 0;
	int c1 = g[i][j], c2 = g[i][g[i].size()-1-j];
	rep(le, 2) rep(ri, 2) rep(leb, 2) rep(rib, 2) {
		if(c1 == c2 && (le != ri || leb != rib)) continue;
		if(leb == 0 && le == 1) continue;
		if(rib == 0 && ri == 1) continue;
		mint x = 1;
		if(c1 != c2) {
			x *= rec3(i, j+1, left ^ le, right ^ ri,
				notperm || ( left != (siz ^ 1 ^ le ^ right) && leb == 1)
				        || (right != (siz ^ 1 ^ ri ^  left) && rib == 1),
				siz ^ le ^ ri);
		}else {
			x *= rec3(i, j+1, left ^ le, right ^ ri,
				notperm || ( left != (siz ^ 1 ^ le ^ right) && leb == 1),
				siz ^ le);
		}
		if(leb == 1)
			x *= rec3(c1, 0, 0, 0, false, le);
		if(rib == 1 && c1 != c2)
			x *= rec3(c2, 0, 0, 0, false, ri);
		r += x;
	}
	return r;
}

int main() {
	int n;
	scanf("%d", &n);
	g.assign(n, vi());
	reu(i, 1, n) {
		int p;
		scanf("%d", &p), -- p;
		g[p].push_back(i);
	}
	subtreesize.assign(n, 0);
	dfs(0);
	tree_getstateindices(0);
	mint initt; initt.x = -1;
	rep(k, 16)
		memo[k].assign(nstates, initt);
	mint ans = 0;
	ans += rec3(0, 0, 0, 0, false, 0);
	ans += rec3(0, 0, 0, 0, false, 1);
	printf("%d\n", ans.get());
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long, long long> pll; typedef vector<pair<long long, long long> > vpll;
typedef vector<string> vs; typedef long double ld;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt(): x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
typedef ModInt<1000000007> mint;

vector<vi> g;
vector<int> subtreesize;

int dfs(int i) {
	int r = 1;
	each(j, g[i])
		r += dfs(*j);
	return subtreesize[i] = r;
}

vector<vi> stateidx;
vi t_ord;
int nstates = 0;

void tree_getstateindices(int root) {
	int n = g.size();
	stateidx.assign(n, vi());
	t_ord.clear();
	nstates = 0;

	vector<int> stk; stk.push_back(root);
	while(!stk.empty()) {
		int i = stk.back(); stk.pop_back();
		t_ord.push_back(i);
		stateidx[i].assign(g[i].size() + 1, -1);
		rep(j, g[i].size()) {
			int c = g[i][j];
			stk.push_back(c);
			stateidx[i][j] = nstates ++;
		}
		stateidx[i][g[i].size()] = nstates ++;
	}
}

inline int getstateindex(int i, int j) {
	int s = stateidx[i][j];
	return s != -1 ? s : stateidx[i][j+1];
}

vector<mint> memo[16];
mint rec3(int i, int j, int left, int right, bool notperm, int siz) {
	int s = stateidx[i][j];
	mint &r = memo[left * 8 + right * 4 + notperm * 2 + siz][s];
	if(r.get() != -1) return r;
	if(j == (g[i].size() + 1) / 2)
		return r = siz == 1 ? (notperm ? 2 : 1) : 0;
	r = 0;
	int c1 = g[i][j], c2 = g[i][g[i].size()-1-j];
	rep(le, 2) rep(ri, 2) rep(leb, 2) rep(rib, 2) {
		if(c1 == c2 && (le != ri || leb != rib)) continue;
		if(leb == 0 && le == 1) continue;
		if(rib == 0 && ri == 1) continue;
		mint x = 1;
		if(c1 != c2) {
			x *= rec3(i, j+1, left ^ le, right ^ ri,
				notperm || ( left != (siz ^ 1 ^ le ^ right) && leb == 1)
				        || (right != (siz ^ 1 ^ ri ^  left) && rib == 1),
				siz ^ le ^ ri);
		}else {
			x *= rec3(i, j+1, left ^ le, right ^ ri,
				notperm || ( left != (siz ^ 1 ^ le ^ right) && leb == 1),
				siz ^ le ^ ri);
		}
		if(leb == 1)
			x *= rec3(c1, 0, 0, 0, false, le);
		if(rib == 1 && c1 != c2)
			x *= rec3(c2, 0, 0, 0, false, ri);
		r += x;
	}
	return r;
}

int main() {
	int n;
	scanf("%d", &n);
	g.assign(n, vi());
	reu(i, 1, n) {
		int p;
		scanf("%d", &p), -- p;
		g[p].push_back(i);
	}
	subtreesize.assign(n, 0);
	dfs(0);
	tree_getstateindices(0);
	mint initt; initt.x = -1;
	rep(k, 16)
		memo[k].assign(nstates, initt);
	mint ans = 0;
	ans += rec3(0, 0, 0, 0, false, 0);
	ans += rec3(0, 0, 0, 0, false, 1);
	printf("%d\n", ans.get());
	return 0;
}


//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <cassert>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
//#include <unordered_set>
//#include <unordered_map>
#define  RD(x)      scanf("%d", &x)
#define  REP(i, n)  for (int i=0; i<int(n); i++)
#define  FOR(i, n)  for (int i=1; i<=int(n); i++)
#define  pii        pair<int, int>
#define  mp         make_pair
#define  pb         push_back
inline   int read(){int ret; scanf("%d", &ret); return ret;}
//int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
#define  N   123456
#define  M   22222
#define  eps 1e-8
#define  pi  acos(-1.0)
#define  inf 0XFFFFFFF
#define  mod 1000000007ll
#define  LL  long long
#define  ULL unsigned long long

LL dp[N][2];
vector<int> node[N];

void dfs(int u) {
	for (int v : node[u])
		dfs(v);

	dp[u][1] = 1;
	dp[u][0] = 0;

	for (int v : node[u]) {
		LL n0 = (dp[u][0] * dp[v][0] % mod + dp[u][1] * dp[v][1] % mod) % mod;
		LL n1 = (dp[u][0] * dp[v][1] % mod + dp[u][1] * dp[v][0] % mod) % mod;
		dp[u][0] = (dp[u][0] + n0) % mod;
		dp[u][1] = (dp[u][1] + n1) % mod;
	}

	dp[u][0] = dp[u][0] * 2 % mod;
	dp[u][1] = dp[u][1] * 2 % mod;

	LL dp0 = 1;
	for (int v : node[u]) {
		dp0 = (dp0 + dp0 * dp[v][0]) % mod;
	}

	LL dp10 = 1;
	LL dp11 = 0;
	for (int v : node[u]) {
		LL n11 = dp10 * dp[v][1] % mod;
		LL n10 = dp11 * dp[v][1] % mod;
		dp10 = (dp10 + n10) % mod;
		dp11 = (dp11 + n11) % mod;
	}

	dp[u][1] = (dp[u][1] + mod - dp0) % mod;
	dp[u][0] = (dp[u][0] + mod - dp11) % mod;

}

int Main() {
//	freopen("cf.txt", "r", stdin);
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n;
	for (int i = 2; i <= n; i++) {
		int p;
		cin >> p;
		node[p].push_back(i);
	}
	dfs(1);
	cout << (dp[1][0] + dp[1][1]) % mod << endl;

	return 0;
}

int main() {
	return Main();
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <cassert>

#define REP(AA,BB) for(int AA=0; AA<(BB); ++AA)
#define FOR(AA,BB,CC) for(int AA=(BB); AA<(CC); ++AA)
#define FC(AA,BB) for(__typeof((AA).begin()) BB=(AA).begin(); BB!=(AA).end(); ++BB)
#define SZ(AA) ((int)((AA).size()))
#define ALL(AA) (AA).begin(), (AA).end()
#define PB push_back
#define MP make_pair

using namespace std;

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long LL;
typedef long double LD;

const int MAXN = 100000, MOD = 1000000007;
VI ve[MAXN];

int ra(int, int, int, int);
int rb(int, int, int);
int da[MAXN][2][2][2], db[MAXN][2][2];

int comp(int v, int x, int y) {
  int res = ra(v, 1 - x, y, 0) + ra(v, 1 - x, y, 1);
  res = (res % MOD + MOD - rb(v, 1 - x, y)) % MOD;
  //printf("%d %d %d -> %d\n", v, x, y, res);
  return res;
}

int ra(int v, int x, int y, int d) {
  if (da[v][x][y][d] != -1) {
    return da[v][x][y][d];
  }
  int dp[2][2][2] = {0};
  dp[1][y][y] = 1;
  for (int i = 0; i < SZ(ve[v]); ++i) {
    int w = d ? ve[v][i] : ve[v][SZ(ve[v]) - i - 1];
    int z = i % 2;
    REP (j, 2) {
      REP (k, 2) {
        dp[z][j][k] = dp[1 - z][j][k];
        REP (l, 2) {
          dp[z][j][k] += (LL)dp[1 - z][l][k] * comp(w, j, l) % MOD;
          dp[z][j][k] %= MOD;
        }
      }
    }
  }
  return da[v][x][y][d] = dp[(SZ(ve[v]) + 1) % 2][x][y];
}

int rb(int v, int x, int y) {
  if (db[v][x][y] != -1) {
    return db[v][x][y];
  }
  int dp[2][2] = {0};
  dp[1][1] = 1;
  dp[1][0] = x == y ? 1 : 0;
  for (int i = 0; i < SZ(ve[v]); ++i) {
    int z = i % 2;
    dp[z][0] = dp[1 - z][0];
    dp[z][0] += (LL)dp[1 - z][1] * comp(ve[v][i], x, y) % MOD;
    dp[z][0] %= MOD;
    dp[z][1] = dp[1 - z][1];
    dp[z][1] += (LL)dp[1 - z][0] * comp(ve[v][i], y, x) % MOD;
    dp[z][1] %= MOD;
  }
  return db[v][x][y] = dp[(SZ(ve[v]) + 1) % 2][0];
}

int main(void) {
  int n; scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int p; scanf("%d", &p); --p;
    ve[p].PB(i);
  }
  REP (i, n) {
    sort(ALL(ve[i]));
  }
  memset(da, -1, sizeof da);
  memset(db, -1, sizeof db);
  int res = comp(0, 0, 0) + comp(0, 0, 1);
  printf("%d\n", res % MOD);
  return 0;
}


// .... .... .....!
// ...... ......!
// .... ....... ..... ..!

#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; i++)
#define fer(i, x, n) for (int i = (int)(x), _n = (int)(n); i < _n; i++)
#define rof(i, n, x) for (int i = (int)(n), _x = (int)(x); i-- > _x; )
#define sz(x) (int((x).size()))
#define pb push_back
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second

template<class P, class Q> inline void smin(P &a, Q b) { if (b < a) a = b; }
template<class P, class Q> inline void smax(P &a, Q b) { if (a < b) a = b; }

typedef long long ll;
typedef pair<int, int> pii;

////////////////////////////////////////////////////////////////////////////////

const int mod = 1000000000+7;
const int maxn = 100000 + 100;

int n;
vector<int> ch[maxn];
int dp[maxn][2];

inline void addto(int &x, int y) {
	x += y;
	if(x >= mod) x -= mod;
}

void dfs(int u) {
	int same[2] = {1, 0}, alt[2] = {1, 0};

	for(int v: ch[u]) {
		dfs(v);

		int s0 = same[0], s1 = same[1];
		addto(same[0], s1 * (ll)dp[v][0] % mod);
		addto(same[1], s0 * (ll)dp[v][0] % mod);

		int a0 = alt[0], a1 = alt[1];
		addto(alt[0], a1 * (ll)dp[v][1] % mod);
		addto(alt[1], a0 * (ll)dp[v][1] % mod);
	}

	pii p = {0, 1};
	pii q = {0, 1};

	rep(i, sz(ch[u])) {
		int v = ch[u][i];
		int d0 = p.X, d1 = p.Y;
		addto(p.X, d0 * (ll)dp[v][0] % mod);
		addto(p.X, d1 * (ll)dp[v][1] % mod);
		addto(p.Y, d1 * (ll)dp[v][0] % mod);
		addto(p.Y, d0 * (ll)dp[v][1] % mod);
	}

	rof(i, sz(ch[u]), 0) {
		int v = ch[u][i];
		int d0 = q.X, d1 = q.Y;
		addto(q.X, d0 * (ll)dp[v][0] % mod);
		addto(q.X, d1 * (ll)dp[v][1] % mod);
		addto(q.Y, d1 * (ll)dp[v][0] % mod);
		addto(q.Y, d0 * (ll)dp[v][1] % mod);
	}

	dp[u][0] = (p.X + (ll)q.X - alt[1] + mod) % mod;
	dp[u][1] = (p.Y + (ll)q.Y - same[0] - same[1] + mod + mod) % mod;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);

	cin >> n;
	fer(i, 1, n) {
		int p;
		cin >> p, p--;
		ch[p].pb(i);
	}

	dfs(0);

	cout << (dp[0][0] + dp[0][1]) % mod << endl;

	return 0;
}


// .... .... .....!
// ...... ......!
// .... ....... ..... ..!

#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; i++)
#define fer(i, x, n) for (int i = (int)(x), _n = (int)(n); i < _n; i++)
#define rof(i, n, x) for (int i = (int)(n), _x = (int)(x); i-- > _x; )
#define sz(x) (int((x).size()))
#define pb push_back
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second

template<class P, class Q> inline void smin(P &a, Q b) { if (b < a) a = b; }
template<class P, class Q> inline void smax(P &a, Q b) { if (a < b) a = b; }

typedef long long ll;
typedef pair<int, int> pii;

////////////////////////////////////////////////////////////////////////////////

const int mod = 1000000000+7;
const int maxn = 100000 + 100;

int n;
vector<int> ch[maxn];
int dp[maxn][2];

inline void addto(int &x, int y) {
	x += y;
	if(x >= mod) x -= mod;
}

void dfs(int u) {
	int same[2] = {1, 0}, alt[2] = {1, 0};

	for(int v: ch[u]) {
		dfs(v);

		int s0 = same[0], s1 = same[1];
		addto(same[0], s1 * (ll)dp[v][0] % mod);
		addto(same[1], s0 * (ll)dp[v][0] % mod);

		int a0 = alt[0], a1 = alt[1];
		addto(alt[0], a1 * (ll)dp[v][1] % mod);
		addto(alt[1], a0 * (ll)dp[v][1] % mod);
	}

	pii p = {0, 1};
	pii q = {0, 1};

	rep(i, sz(ch[u])) {
		int v = ch[u][i];
		int d0 = p.X, d1 = p.Y;
		addto(p.X, d0 * (ll)dp[v][0] % mod);
		addto(p.X, d1 * (ll)dp[v][1] % mod);
		addto(p.Y, d1 * (ll)dp[v][0] % mod);
		addto(p.Y, d0 * (ll)dp[v][1] % mod);
	}

	rof(i, sz(ch[u]), 0) {
		int v = ch[u][i];
		int d0 = q.X, d1 = q.Y;
		addto(q.X, d0 * (ll)dp[v][0] % mod);
		addto(q.X, d1 * (ll)dp[v][1] % mod);
		addto(q.Y, d1 * (ll)dp[v][0] % mod);
		addto(q.Y, d0 * (ll)dp[v][1] % mod);
	}

	dp[u][0] = (p.X + q.X - alt[1] + mod) % mod;
	dp[u][1] = (p.Y + (ll)q.Y - same[0] - same[1] + mod + mod) % mod;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);

	cin >> n;
	fer(i, 1, n) {
		int p;
		cin >> p, p--;
		ch[p].pb(i);
	}

	dfs(0);

	cout << (dp[0][0] + dp[0][1]) % mod << endl;

	return 0;
}