#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 1;
int n, F[N], dp[N][26], m, res;
vector<pair<int, string> > g[100000];
char s[N];
int calc(int at, char c) {
  int &res = dp[at][c];
  if (res != -1) return res;
  if (at != 0 && s[at] != c) at = calc(F[at - 1], c);
  if (s[at] == c) ++at;
  return res = at;
}
void DFS(int v, int cur) {
  for (int i = 0; i < g[v].size(); ++i) {
    string &z = g[v][i].second;
    int at = cur;
    for (int j = 0; j < z.size(); ++j) {
      at = calc(at, z[j]);
      if (at == m) ++res;
    }
    DFS(g[v][i].first, at);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x; i < n; ++i) {
    scanf("%d%s", &x, s);
    g[--x].push_back(make_pair(i, s));
  }
  scanf("%s", s);
  m = strlen(s);
  for (int i = 1, k = 0; i < m; ++i) {
    while (k != 0 && s[i] != s[k]) k = F[k - 1];
    if (s[i] == s[k]) ++k;
    F[i] = k;
  }
  memset(dp, -1, sizeof dp);
  DFS(0, 0);
  printf("%d\n", res);
  return 0;
}
