#include <bits/stdc++.h>
using namespace std;
int answ, n, x, q, pi[1000001], fix[2000001];
string st1, st;
vector<pair<int, string>> v[2000001];
pair<int, int> get_ans(int q, int pr, int x) {
  pair<int, int> ans;
  ans.first = 0;
  ans.second = 0;
  string s = v[pr][x].second;
  for (int i = 1; i <= s.size(); i++) {
    while (s[i - 1] - st[q] && q > 0) {
      q = pi[q];
      if (q + s.size() - i + 1 < st.size() && !v[v[pr][x].first].size()) break;
    }
    if (st[q] == s[i - 1]) q++;
    if (q == st.size()) ans.first++, q = pi[q];
  }
  ans.second = q;
  return ans;
}
void dfs(int x, int q, int pr, int idx) {
  if (fix[x]) return;
  fix[x] = 1;
  pair<int, int> p;
  if (pr) {
    p = get_ans(q, pr, idx);
    answ += p.first;
  } else
    p.second = q;
  for (int i = 0; i < v[x].size(); i++) {
    dfs(v[x][i].first, p.second, x, i);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x >> st1;
    v[x].push_back({i + 1, st1});
  }
  cin >> st;
  pi[1] = 0, q = 0;
  for (int i = 2; i <= st.size(); i++) {
    while (st[i - 1] - st[q] && q > 0) q = pi[q];
    if (st[q] == st[i - 1]) q++;
    pi[i] = q;
  }
  dfs(1, 0, 0, 1);
  cout << answ;
}
