#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const double pi = acos(-1.0);
vector<int> prefixFunc(const string &s) {
  vector<int> f((int)(s).size());
  int k = 0;
  for (int _b = ((int)(s).size() - 1), i = (1); i <= _b; i++) {
    while (k && s[k] != s[i]) k = f[k - 1];
    if (s[k] == s[i]) ++k;
    f[i] = k;
  }
  return f;
}
int KMPsearch(const string &s, const vector<int> &f, const string &p, int &k) {
  int res = 0;
  for (int i = 0, _n = ((int)(s).size()); i < _n; i++) {
    while (k && p[k] != s[i]) k = f[k - 1];
    if (p[k] == s[i]) ++k;
    if (k == (int)(p).size()) k = f[k - 1], res++;
  }
  return res;
}
int n;
string s[111000], t;
vector<int> a[111000];
vector<int> prefix;
int res;
queue<pair<int, int> > q;
int main() {
  cin >> n;
  s[0] = "";
  for (int i = 0, _n = (n); i < _n; i++)
    if (i) {
      int p;
      cin >> p >> s[i];
      a[p - 1].push_back(i);
    }
  cin >> t;
  prefix = prefixFunc(t);
  res = 0;
  q.push(pair<int, int>(0, 0));
  while (!q.empty()) {
    int v = q.front().first;
    int k = q.front().second;
    q.pop();
    res += KMPsearch(s[v], prefix, t, k);
    for (int i = 0, _n = ((int)(a[v]).size()); i < _n; i++)
      q.push(pair<int, int>(a[v][i], k));
  }
  cout << res << endl;
  return 0;
}
