#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  int to;
  string s;
};
vector<node> bian[100005];
int ans;
char a[100005];
int next1[100005];
int lena;
void get_next(char *b) {
  next1[0] = -1;
  int k = -1;
  int lenb = strlen(b);
  for (int i = 1; i < lenb; i++) {
    while (k >= 0 && b[k + 1] != b[i]) {
      k = next1[k];
    }
    if (b[k + 1] == b[i]) k++;
    if (b[i + 1] == b[k + 1])
      next1[i] = next1[k + 1];
    else
      next1[i] = k;
  }
}
void dfs(int now, int nowj, int fa) {
  for (int i = 0; i < bian[now].size(); i++) {
    if (bian[now][i].to == fa) return;
    string temp = bian[now][i].s;
    int lens = temp.size();
    int j = nowj;
    for (int k = 0; k < lens; k++) {
      while (j >= 0 && a[j + 1] != temp[k]) {
        j = next1[j];
      }
      if (a[j + 1] == temp[k]) j++;
      if (j == lena - 1) {
        ans++;
        j = next1[j];
      }
    }
    dfs(bian[now][i].to, j, now);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int p;
    string temp;
    cin >> p;
    cin >> temp;
    bian[p].push_back(node{i, temp});
  }
  cin >> a;
  lena = strlen(a);
  get_next(a);
  dfs(1, -1, 0);
  cout << ans;
  return 0;
}
