#include <bits/stdc++.h>
using namespace std;
struct st {
  int v, a, b;
};
st str;
vector<st> gr[1000001];
char S[300002], P[100002];
int kmp[1000001];
int n, i, ans, a, m, u;
void dfs(int u, int q) {
  int q0 = q;
  for (int r = 0; r < gr[u].size(); r++) {
    int q = q0, v = gr[u][r].v;
    for (int i = gr[u][r].a; i < gr[u][r].b; i++) {
      while (P[q + 1] != S[i] && q > 0) {
        q = kmp[q];
        if (gr[v].size() == 0 && q + gr[u][r].b - i < m) break;
      }
      if (P[q + 1] == S[i]) q++;
      if (q == m) {
        ans++;
        q = kmp[q];
      }
    }
    dfs(v, q);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d %s", &u, S + a);
    int l = strlen(S + a);
    str.v = i;
    str.a = a;
    str.b = a + l;
    gr[u].push_back(str);
    a += l;
  }
  scanf("%s", P + 1);
  P[0] = '#';
  m = strlen(P) - 1;
  int q = 0;
  kmp[1] = 0;
  for (int i = 2; i <= m; i++) {
    while (P[q + 1] != P[i] && q > 0) q = kmp[q];
    if (P[q + 1] == P[i]) q++;
    kmp[i] = q;
  }
  dfs(1, 0);
  cout << ans << endl;
}
