#include <bits/stdc++.h>
using namespace std;
unsigned long long X = 71;
unsigned long long x[5000000], H;
vector<int> v[200000];
char S[5000000], str[5000000], tmp[5000000];
char *s[200000];
int length, L, l[200000];
int answer, N;
int ch(char c) { return int(c - 'a' + 1); }
void recalc(unsigned long long &h, int &hl, char c) {
  if (hl == L) {
    h = (h - x[L - 1] * ch(S[length - L])) * X;
    hl--;
  }
  h += ch(c) * x[L - 1 - hl++];
}
void DFS(int num, unsigned long long h, int hl) {
  int i, col = v[num].size();
  for (i = 0; s[num] && s[num][i]; i++) {
    recalc(h, hl, s[num][i]);
    S[length++] = s[num][i];
    S[length] = NULL;
    if (h == H && hl == L) answer++;
  }
  for (i = 0; i < col; i++) DFS(v[num][i], h, hl);
  length -= l[num];
  S[length] = NULL;
}
void GetString(int num) {
  scanf("%s", &tmp);
  int i;
  l[num] = strlen(tmp);
  s[num] = (char *)malloc((l[num] + 2) * sizeof(char));
  for (i = 0; tmp[i - 1] || !i; i++) s[num][i] = tmp[i];
}
int main() {
  int i, p;
  scanf("%d", &N);
  for (i = 2; i <= N; i++) {
    scanf("%d", &p);
    GetString(i);
    v[p].push_back(i);
  }
  scanf("%s", &str);
  L = strlen(str);
  for (x[0] = 1, i = 1; i <= L; x[i] = x[i - 1] * X, i++)
    ;
  for (i = 0; i < L; i++) H += ch(str[i]) * x[L - 1 - i];
  DFS(1, 0, 0);
  printf("%d", answer);
  return 0;
}
