#include <bits/stdc++.h>
using namespace std;
const unsigned long long p = 107;
struct node {
  int next, to;
} e[400020 * 2];
int head[400020], cnt, tot;
int sz[400020], fa[400020], son[400020], n;
int col[400020], mx, vis[400020], dth[400020], a[400020], l[400020], r[400020],
    dfstime, len;
unsigned long long h[400020], tmp, pow_;
long long ans;
char ch[400020];
inline void adde(int x, int y) {
  e[++cnt].to = y;
  e[cnt].next = head[x];
  head[x] = cnt;
}
inline unsigned long long gethash(int id, int len) {
  return h[id] - h[id - len] * pow_;
}
void dfs1(int x, int sz = 0) {
  for (int i = head[x]; i; i = e[i].next) {
    if (e[i].to == fa[x]) continue;
    fa[e[i].to] = x;
    dth[e[i].to] = dth[x] + 1;
    h[sz + 1] = h[sz] * p + col[e[i].to];
    if (gethash(sz + 1, len) == tmp) ans++;
    dfs1(e[i].to, sz + 1);
  }
}
int main() {
  scanf("%d", &n);
  tot = n;
  for (int i = 2; i <= n; ++i) {
    scanf("%d%s", &fa[i], ch);
    int len = strlen(ch), last = fa[i];
    for (int j = 0; j <= len - 2; ++j) {
      ++tot;
      col[tot] = ch[j] - 'a' + 1;
      adde(last, tot);
      last = tot;
    }
    col[i] = ch[len - 1] - 'a' + 1, adde(last, i);
  }
  scanf("%s", ch);
  len = strlen(ch);
  pow_ = 1;
  for (int i = 0; i <= len - 1; ++i) tmp = tmp * p + ch[i] - 'a' + 1, pow_ *= p;
  dfs1(1);
  printf("%lld\n", ans);
}
