#include <bits/stdc++.h>
using namespace std;
int const lim = 3e5 + 1;
int const MLOG = 20, mod = 1e9 + 7, bas = 47;
string s[lim + 3];
vector<int> adj[lim + 3];
int st[4 * lim + 3], poww[lim + 3];
void update(int i, int j, int index, int ind, int val) {
  if (i > ind || j < ind) return;
  if (i == j && i == ind) {
    st[index] = val;
    return;
  }
  int mid = (i + j) / 2;
  update(i, mid, index * 2 + 1, ind, val);
  update(mid + 1, j, index * 2 + 2, ind, val);
  st[index] = (0ll + st[index * 2 + 1] +
               ((1ll * st[index * 2 + 2] * poww[mid - i + 1]) % mod)) %
              mod;
}
int get(int i, int j, int index, int l, int r) {
  if (i > r || j < l) return 0;
  if (i >= l && j <= r) return st[index];
  int mid = (i + j) / 2;
  int val1 = get(i, mid, index * 2 + 1, l, r);
  int val2 = get(mid + 1, j, index * 2 + 2, l, r);
  if (l > mid) return val2;
  if (r < mid + 1) return val1;
  int mn = min(mid - i + 1, mid - l + 1);
  return (0ll + val1 + ((1ll * val2 * poww[mn]) % mod)) % mod;
}
long long hashing = 0, ans = 0, sz = 0;
void dfs(int u, int p, int ind) {
  for (int i = 0; i < adj[u].size(); i++) {
    int che = adj[u][i];
    int tem = ind;
    for (int j = 0; j < s[che].size(); j++) {
      update(0, lim, 0, tem, s[che][j] - 'a' + 1);
      int val = 0;
      if (tem + 1 >= sz) val = get(0, lim, 0, tem - sz + 1, tem);
      if (val == hashing) ans++;
      tem++;
    }
    dfs(che, u, tem);
  }
}
int main() {
  poww[0] = 1;
  for (int i = 1; i < lim; i++) poww[i] = (1ll * poww[i - 1] * bas) % mod;
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int u;
    cin >> u >> s[i];
    adj[u].push_back(i);
  }
  string inp;
  cin >> inp;
  sz = inp.size();
  for (int i = 0; i < inp.size(); i++) {
    hashing += (1ll * (inp[i] - 'a' + 1) * poww[i]) % mod;
    hashing %= mod;
  }
  dfs(1, -1, 0);
  cout << ans << endl;
}
