#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 19;
const int N = 4e5 + 100;
const int P = 31;
vector<int> g[N];
int n, lev[N], sm, lq, answer;
char ss[N], pch[N];
long long pw[N], h[N], hq;
vector<int> stk;
void dfs(int v, int p, int lev) {
  stk.push_back(v);
  if (p != -1) h[v] = (h[p] + pw[lev - 1] * pch[v]) % MOD;
  if (lev >= lq) {
    long long res = h[v] - h[stk[lev - lq]];
    if (res < 0) res += MOD;
    res *= pw[sm - (lev - lq)];
    res %= MOD;
    if (hq * pw[sm] % MOD == res) answer++;
  }
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    dfs(to, v, lev + 1);
  }
  stk.pop_back();
}
int main() {
  pw[0] = 1;
  for (int i = 1; i < N; ++i) pw[i] = pw[i - 1] * P % MOD;
  cin >> n;
  int sz = n;
  sm = n + 1;
  for (int i = 1; i < n; ++i) {
    int p;
    scanf("%d%s", &p, ss);
    int len = strlen(ss);
    if (len == 1) {
      g[p - 1].push_back(i);
      pch[i] = ss[0] - 'a' + 1;
      continue;
    }
    g[p - 1].push_back(sz);
    pch[sz] = ss[0] - 'a' + 1;
    sz++;
    sm += len;
    for (int j = 1; j + 1 < len; ++j) {
      g[sz - 1].push_back(sz);
      pch[sz] = ss[j] - 'a' + 1;
      sz++;
    }
    g[sz - 1].push_back(i);
    pch[i] = ss[len - 1] - 'a' + 1;
  }
  scanf("%s", ss);
  lq = strlen(ss);
  hq = ss[0] - 'a' + 1;
  for (int i = 1; i < lq; ++i) hq = (hq + (ss[i] - 'a' + 1) * pw[i]) % MOD;
  dfs(0, -1, 0);
  cout << answer;
  return 0;
}
