#include <bits/stdc++.h>
using namespace std;
const int Maxs = 300 * 1000 + 5, Maxn = 100 * 1000 + 5;
int n, dp[Maxs], nxt[Maxs][26];
char s[Maxs];
long long ans;
string t;
vector<int> adj[Maxn];
vector<string> str[Maxn];
void kmp() {
  dp[0] = -1;
  for (int i = 0; i < (int)t.size(); i++) {
    int pt = i;
    while (dp[pt] != -1 && t[dp[pt]] != t[i]) pt = dp[pt];
    dp[i + 1] = dp[pt] + 1;
  }
  return;
}
void dfs(int v, int indt) {
  for (int i = 0; i < adj[v].size(); i++) {
    int indt2 = indt;
    for (int j = 0; j < (int)str[v][i].size(); j++) {
      if (indt2 == (int)t.size()) ans++;
      indt2 = nxt[indt2 + 1][str[v][i][j] - 'a'];
    }
    if (indt2 == (int)t.size()) {
      ans++;
      indt2 = dp[indt2];
    }
    dfs(adj[v][i], indt2);
  }
  return;
}
int main() {
  scanf("%d", &n);
  int par;
  for (int i = 1; i < n; i++) {
    scanf("%d%s", &par, s);
    par--;
    adj[par].push_back(i);
    str[par].push_back(s);
  }
  scanf("%s", s);
  t = s;
  kmp();
  for (int i = 1; i <= (int)t.size() + 1; i++) {
    for (int j = 0; j < 26; j++) {
      if (i <= (int)t.size() && t[i - 1] - 'a' == j)
        nxt[i][j] = i;
      else
        nxt[i][j] = nxt[dp[i - 1] + 1][j];
    }
  }
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}
