#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
string pat, s[(int)5e5 + 100];
vector<int> ret, adj[(int)5e5 + 100];
int nxt[(int)5e5 + 100][26];
int m;
void preffixFunc() {
  ret.resize(pat.size(), 0);
  for (int i = 1, k = 0; i < pat.size(); i++) {
    while (k && pat[i] != pat[k]) k = ret[k - 1];
    if (pat[i] == pat[k]) k++;
    ret[i] = k;
  }
}
long long ans = 0;
void dfs(int u = 0, int p = -1, int oldK = 0) {
  for (auto x : adj[u])
    if (x != p) {
      int k = oldK;
      for (int i = 0; i < s[x].size(); i++) {
        k = nxt[k][s[x][i] - 'a'];
        if (k == m) ans++, k = ret[k - 1];
      }
      dfs(x, u, k);
    }
}
char c[1000100];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int par;
    scanf("%d", &par);
    scanf("%s", &c);
    s[i] = string(c);
    adj[par - 1].push_back(i);
  }
  scanf("%s", &c);
  pat = string(c);
  m = pat.size();
  preffixFunc();
  for (int i = 0; i < pat.size(); i++)
    for (int j = 0; j < 26; j++)
      nxt[i][j] = (pat[i] - 'a' == j ? i + 1 : (i ? nxt[ret[i - 1]][j] : 0));
  dfs();
  printf("%I64d\n", ans);
  return 0;
}
