#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10;
vector<pair<string, int> > ch[MAXN];
int nxt[MAXN][27], n, gp, ans;
string t;
void adds(string &tmp) {
  for (int i = 0; i < tmp.size(); i++) {
    gp = nxt[gp][tmp[i] - 'a'];
    if (gp == t.size()) ans++;
  }
}
void dfs(int v, int p) {
  for (int i = 0; i < ch[v].size(); i++) {
    gp = p;
    adds(ch[v][i].first);
    dfs(ch[v][i].second, gp);
  }
}
int main() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    string tmp;
    int r;
    cin >> r >> tmp;
    ch[r].push_back({tmp, i});
  }
  cin >> t;
  nxt[0][t[0] - 'a'] = 1;
  int cp = 0;
  for (int i = 1; i <= t.size(); i++) {
    for (char c = 'a'; c <= 'z'; c++) {
      if (t[cp] == c)
        nxt[i][c - 'a'] = cp + 1;
      else
        nxt[i][c - 'a'] = nxt[cp][c - 'a'];
    }
    if (i < t.size()) {
      nxt[i][t[i] - 'a'] = i + 1;
      if (t[cp] == t[i])
        cp++;
      else
        cp = nxt[cp][t[i] - 'a'];
    }
  }
  dfs(1, 0);
  cout << ans;
}
