#include <bits/stdc++.h>
using namespace std;
long long int req1, req2, len;
map<pair<int, int>, int> mp;
vector<int> v[100002];
vector<string> st[100002];
int ans = 0;
long long int po(long long int a, long long int b, long long int mod) {
  long long int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b = b >> 1;
  }
  return ans;
}
void dfs(int node, int par, long long int till1, long long int till2) {
  int i, l, j;
  for (i = 0; i < v[node].size(); i++) {
    if (v[node][i] == par) continue;
    string s = st[node][i];
    l = s.length();
    for (j = 0; j < l; j++) {
      till1 = (till1 * 26 + s[j] - 'a' + 1) % 1000000007;
      till2 = (till2 * 26 + s[j] - 'a' + 1) % 1000000009;
      long long int ss1 = (till1 - req1 + 1000000007) % 1000000007,
                    ss2 = (till2 - req2 + 1000000009) % 1000000009;
      ss1 = (ss1 * po(po(26, 1000000007 - 2, 1000000007), len, 1000000007)) %
            1000000007;
      ss2 = (ss2 * po(po(26, 1000000009 - 2, 1000000009), len, 1000000009)) %
            1000000009;
      if (mp.find(make_pair(ss1, ss2)) != mp.end()) {
        ans++;
      }
      mp[make_pair(till1, till2)]++;
    }
    dfs(v[node][i], node, till1, till2);
    for (j = l - 1; j >= 0; j--) {
      mp[make_pair(till1, till2)]--;
      if (mp[make_pair(till1, till2)] == 0) mp.erase(make_pair(till1, till2));
      till1 = (till1 - s[j] + 'a' - 1) % 1000000007;
      till1 = (till1 * po(26, 1000000007 - 2, 1000000007)) % 1000000007;
      till2 = (till2 - s[j] + 'a' - 1) % 1000000009;
      till2 = (till2 * po(26, 1000000009 - 2, 1000000009)) % 1000000009;
    }
  }
}
int main() {
  int n, a, i;
  string s;
  scanf("%d", &n);
  for (i = 2; i <= n; i++) {
    scanf("%d", &a);
    v[a].push_back(i);
    cin >> s;
    st[a].push_back(s);
  }
  cin >> s;
  mp[make_pair(0, 0)] = 1;
  len = s.length();
  for (i = 0; i < len; i++) {
    req1 = (req1 * 26 + s[i] - 'a' + 1) % 1000000007;
    req2 = (req2 * 26 + s[i] - 'a' + 1) % 1000000009;
  }
  dfs(1, 0, 0, 0);
  printf("%d\n", ans);
  return 0;
}
