#include <bits/stdc++.h>
using namespace std;
const int maxN = 100 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
const int maxM = 400000;
vector<pair<int, string> > a[maxN];
int f[maxN];
string s;
int ans;
void dfs(int v, int ss = 0) {
  for (auto xx : a[v]) {
    int u = xx.first;
    string t = xx.second;
    int len = ss;
    for (int j = 0; j < t.size(); j++) {
      while (len && (len == s.size() || s[len] != t[j])) len = f[len - 1];
      if (s[len] == t[j]) len++;
      if (len == s.size()) ans++;
    }
    dfs(u, len);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie();
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int p;
    string t;
    cin >> p >> t;
    p--;
    a[p].push_back({i, t});
  }
  cin >> s;
  int len = 0;
  for (int i = 1; i < s.size(); i++) {
    while (len && s[len] != s[i]) len = f[len - 1];
    if (s[len] == s[i]) len++;
    f[i] = len;
  }
  dfs(0);
  cout << ans << endl;
  return 0;
}
