#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
int n, m, cnt;
string s[MAXN];
char t[3 * MAXN];
vector<int> v[MAXN];
int pkmp[MAXN];
void read() {
  int i, x;
  scanf("%d", &n);
  for (i = 2; i <= n; ++i) {
    scanf("%d %s", &x, t);
    s[i] = t;
    v[x].push_back(i);
  }
  scanf("%s", t);
}
void pre_kmp() {
  int i, k = 0;
  for (i = 2; i <= m; ++i) {
    while (k > 0 && t[i - 1] != t[k]) k = pkmp[k];
    if (t[i - 1] == t[k]) ++k;
    pkmp[i] = k;
  }
}
void dfs(int i, int pos) {
  int j, szv = (int)v[i].size();
  for (j = 0; j < szv; ++j) {
    int k = pos;
    for (int e = 0; e < (int)s[v[i][j]].size(); ++e) {
      while (k > 0 && s[v[i][j]][e] != t[k]) k = pkmp[k];
      if (s[v[i][j]][e] == t[k]) ++k;
      if (k == m) cnt++;
    }
    dfs(v[i][j], k);
  }
}
int main() {
  read();
  m = (int)strlen(t);
  pre_kmp();
  dfs(1, 0);
  printf("%d\n", cnt);
  return 0;
}
