#include <bits/stdc++.h>
using namespace std;
string t;
int N;
const int tam = 3e5 + 9;
long long mod1 = 1e9 + 7, mod2 = 1e9 + 9;
long long p1 = 37, p2 = 41, shut1 = 0, shut2 = 0;
long long v1[tam], v2[tam], po1[tam], po2[tam];
struct trie {
  list<pair<string, int> > m;
} tr[tam];
long long exp(long long b, long long e, long long mod) {
  long long ans = 1;
  while (e) {
    if (e & 1) {
      ans = (ans * b) % mod;
    }
    b = (b * b) % mod;
    e >>= 1;
  }
  return ans;
}
long long DFS(int idx = 0, int pos = 1) {
  if (tr[idx].m.size() == 0) {
    return 0;
  }
  long long ans = 0;
  for (auto i : tr[idx].m) {
    for (int j = 0; j < i.first.size(); j++) {
      v1[pos + j] =
          ((po1[pos + j] * (i.first[j] - 'a' + 1)) % mod1 + v1[pos + j - 1]) %
          mod1;
      v2[pos + j] =
          ((po2[pos + j] * (i.first[j] - 'a' + 1)) % mod2 + v2[pos + j - 1]) %
          mod2;
      if (N <= pos + j) {
        if (((v1[pos + j] - v1[pos + j - N] + mod1) % mod1 *
             exp(po1[pos + j - N + 1], mod1 - 2, mod1)) %
                    mod1 ==
                shut1 &&
            ((v2[pos + j] - v2[pos + j - N] + mod2) % mod2 *
             exp(po2[pos + j - N + 1], mod2 - 2, mod2)) %
                    mod2 ==
                shut2)
          ans++;
      }
    }
    ans += DFS(i.second, pos + i.first.size());
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, pv;
  string temp;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> pv >> temp;
    pv--;
    tr[pv].m.push_back(pair<string, int>(temp, i));
  }
  long long a = 1, b = 1;
  for (int i = 0; i < tam; i++) {
    po1[i] = a;
    po2[i] = b;
    a = (a * p1) % mod1;
    b = (b * p2) % mod2;
  }
  cin >> t;
  N = t.size();
  for (int i = 0; i < N; i++) {
    shut1 = (shut1 + (po1[i] * (t[i] - 'a' + 1)) % mod1) % mod1;
    shut2 = (shut2 + (po2[i] * (t[i] - 'a' + 1)) % mod2) % mod2;
  }
  cout << DFS() << '\n';
  return 0;
}
