#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 100;
const int MAXK = 30;
vector<pair<int, string>> ver[MAXN];
int nex[MAXN][MAXK], f[MAXN], val[MAXN], tmp = 0, cnt = 0;
int solve(int cur, string s) {
  for (auto c : s) {
    cur = nex[cur][c - 'a'];
    if (cur == tmp) cnt++, cur = f[cur];
  }
  return cur;
}
void dfs(int v) {
  for (auto e : ver[v]) {
    int u = e.first;
    string s = e.second;
    val[u] = solve(val[v], s);
    dfs(u);
  }
}
int32_t main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    p--;
    string t;
    cin >> t;
    ver[p].push_back({i, t});
  }
  string s;
  cin >> s;
  tmp = s.size();
  for (int i = 0; i < tmp; i++) {
    for (int j = 0; j < MAXK; j++) {
      if (j == s[i] - 'a') {
        nex[i][j] = i + 1;
        f[i + 1] = nex[f[i]][j] * (i > 0);
      } else
        nex[i][j] = nex[f[i]][j];
    }
  }
  dfs(0);
  cout << cnt;
}
