#include <bits/stdc++.h>
using namespace std;
const int H = 1000000007;
const int maxn = 100010;
char s[300010];
vector<char> str[maxn];
vector<int> edge[maxn];
char st[300010];
int tot;
int p[300010];
int target;
int ans;
int sum[524288 * 2 + 10];
int son[524288 * 2 + 10];
int MAX = 300000;
void pushup(int rt) {
  sum[rt] = sum[rt << 1] * p[son[rt << 1 | 1]] + sum[rt << 1 | 1];
  son[rt] = son[rt << 1] + son[rt << 1 | 1];
}
void update(int p, int val, int l, int r, int rt) {
  if (l == r) {
    sum[rt] = val;
    son[rt] = 1;
    return;
  }
  int m = l + r >> 1;
  if (p <= m)
    update(p, val, l, m, rt << 1);
  else
    update(p, val, m + 1, r, rt << 1 | 1);
  pushup(rt);
}
pair<int, int> query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return make_pair(sum[rt], son[rt]);
  }
  int m = l + r >> 1;
  int ret = 0, ls = 0, rs = 0, lsum = 0, rsum = 0;
  if (L <= m) {
    pair<int, int> pl = query(L, R, l, m, rt << 1);
    lsum = pl.first;
    ls += pl.second;
  }
  if (R > m) {
    pair<int, int> pr = query(L, R, m + 1, r, rt << 1 | 1);
    rsum = pr.first;
    rs += pr.second;
  }
  ret = lsum * p[rs] + rsum;
  return make_pair(ret, ls + rs);
}
int now;
void dfs(int u, int f) {
  if (u != 1) {
    int sz = str[u].size();
    for (int i = 0; i < sz; i++) {
      st[++tot] = str[u][i];
      update(tot, str[u][i], 1, MAX, 1);
    }
  }
  int sz = edge[u].size();
  for (int i = 0; i < sz; i++) {
    int v = edge[u][i];
    if (v != f) {
      dfs(v, u);
    }
  }
  int len = str[u].size();
  for (int i = tot; i > tot - len; i--) {
    pair<int, int> h = query(i - now + 1, i, 1, MAX, 1);
    if (h.first == target) ans++;
  }
  tot -= len;
}
int main() {
  p[0] = 1;
  for (int i = 1; i <= 300000; i++) p[i] = p[i - 1] * H;
  int n, a, u;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d%s", &u, s);
    for (int j = 0; s[j]; j++) {
      str[i].push_back(s[j]);
    }
    edge[u].push_back(i);
  }
  scanf("%s", s);
  int len = strlen(s);
  now = len;
  target = 0;
  for (int i = 0; i < len; i++) target = target * H + s[i];
  dfs(1, -1);
  printf("%d\n", ans);
  return 0;
}
