#include <bits/stdc++.h>
using namespace std;
const int maxN = 100 * 1000 + 5;
const int lim = 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000 + 5;
int f[3 * maxN];
vector<pair<int, string> > a[maxN];
string t;
int ans;
void dfs(int v, int F) {
  for (auto u : a[v]) {
    int tmp = F;
    string s = u.second;
    for (int i = 0; i < s.size(); i++) {
      while (tmp && (tmp == t.size() || t[tmp] != s[i])) tmp = f[tmp - 1];
      if (t[tmp] == s[i]) tmp++;
      if (tmp == t.size()) ans++;
    }
    dfs(u.first, tmp);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int par;
    string s;
    cin >> par >> s;
    par--;
    a[par].push_back(make_pair(i, s));
  }
  cin >> t;
  int tmp = 0;
  for (int i = 1; i < t.size(); i++) {
    while (tmp && t[tmp] != t[i]) tmp = f[tmp - 1];
    if (t[tmp] == t[i]) tmp++;
    f[i] = tmp;
  }
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}
