#include <bits/stdc++.h>
using namespace std;
long long int power1[1000001], power2[1000001], lt, h1, h2, ans,
    base = 127, mod1 = 1000000007, mod2 = 1000000009;
string t;
vector<long long int> hash1, hash2;
vector<pair<long long int, string> > v[1000001];
void dfs(long long int cur) {
  for (long long int i = 0; i < v[cur].size(); i++) {
    long long int x = v[cur][i].first;
    string s = v[cur][i].second;
    for (long long int j = 0; j < s.length(); j++) {
      hash1.push_back((hash1.back() * base + s[j] - 'a' + 1) % mod1);
      hash2.push_back((hash2.back() * base + s[j] - 'a' + 1) % mod2);
      if (hash1.size() - lt - 1 >= 0) {
        long long int temp_h1 =
            (((hash1.back() - hash1[hash1.size() - lt - 1] * power1[lt]) %
                  mod1 +
              mod1) %
             mod1);
        long long int temp_h2 =
            (((hash2.back() - hash2[hash2.size() - lt - 1] * power2[lt]) %
                  mod2 +
              mod2) %
             mod2);
        if (temp_h1 == h1 && temp_h2 == h2) ans++;
      }
    }
    dfs(x);
    for (long long int j = 0; j < s.length(); j++) {
      hash1.pop_back();
      hash2.pop_back();
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  ;
  cin.tie(0);
  ;
  long long int i, j, n, x, y;
  string s;
  cin >> n;
  power1[0] = 1;
  for (i = 1; i <= 100000; i++) power1[i] = (power1[i - 1] * base) % mod1;
  power2[0] = 1;
  for (i = 1; i <= 100000; i++) power2[i] = (power2[i - 1] * base) % mod2;
  for (i = 2; i <= n; i++) {
    cin >> x >> s;
    v[x].push_back(make_pair(i, s));
  }
  cin >> t;
  lt = t.length();
  for (i = 0; i < t.length(); i++) {
    h1 = (h1 * base + t[i] - 'a' + 1) % mod1;
    h2 = (h2 * base + t[i] - 'a' + 1) % mod2;
  }
  hash1.push_back(0);
  hash2.push_back(0);
  dfs(1);
  cout << ans;
  return 0;
}
