#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
vector<pair<int, string> > v[maxn];
int nex[maxn];
string t;
int dfs(int x, int l = 0) {
  int ret = 0;
  for (int e = 0; e < v[x].size(); e++) {
    int child = v[x][e].first, tmp = l;
    string &cur = v[x][e].second;
    for (int i = 0; i < cur.size(); i++) {
      while (tmp > 0 && t[tmp] != cur[i]) tmp = nex[tmp - 1];
      if (t[tmp] == cur[i]) tmp++;
      if (tmp == t.size()) tmp = nex[tmp - 1], ret++;
    }
    ret += dfs(child, tmp);
  }
  return ret;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    string s;
    int p;
    cin >> p >> s;
    p--;
    v[p].push_back(make_pair(i, s));
  }
  cin >> t;
  nex[0] = 0;
  int l = 0;
  for (int i = 1; i < t.size(); i++) {
    while (l > 0 && t[i] != t[l]) l = nex[l - 1];
    if (t[i] == t[l]) nex[i] = ++l;
  }
  cout << dfs(0) << endl;
}
