#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
int nex[N], head[N], to[N], cnt, ans, lent, lens[N], nxt[N];
vector<char> s[N];
char st[N], t[N];
void init_nex() {
  nex[0] = nex[1] = 0;
  int j;
  for (int i = 1; i < lent; i++) {
    j = nex[i];
    while (j && t[i] != t[j]) j = nex[j];
    if (t[i] == t[j]) j++;
    nex[i + 1] = j;
  }
  for (int i = 1; i < lent; i++)
    if (t[i] == t[nex[i]]) nex[i] = nex[nex[i]];
}
void add(int x, int y) {
  nxt[++cnt] = head[x];
  head[x] = cnt;
  to[cnt] = y;
}
void dfs(int u, int j) {
  int tmp = j;
  for (int i = head[u]; i; i = nxt[i]) {
    j = tmp;
    int v = to[i];
    for (int k = 0; k < lens[v]; k++) {
      while (s[v][k] != t[j] && j) j = nex[j];
      if (s[v][k] == t[j]) j++;
      if (j == lent) {
        ans++;
        j = nex[j];
      }
    }
    dfs(v, j);
  }
}
int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &x);
    scanf("%s", st);
    lens[i] = strlen(st);
    for (int j = 0; j < lens[i]; j++) s[i].push_back(st[j]);
    add(x, i);
  }
  scanf("%s", t);
  lent = strlen(t);
  init_nex();
  dfs(1, 0);
  printf("%d\n", ans);
  return 0;
}
