#include <bits/stdc++.h>
using namespace std;
const int N = 300100;
int n, need, en;
char al[N];
vector<pair<int, string> > adj[N];
vector<int> pi, K;
string s;
long long ANS;
int dp[26][N];
void pre(int pos, int u, int v) {
  int k = K[u];
  for (int i = pos; i < s.size(); i++) {
    while (k >= 0 && s[k + 1] != s[i]) k = pi[k];
    if (s[k + 1] == s[i]) k++;
    pi[i] = k;
    if (k == need) ANS++;
  }
  K[v] = k;
  return;
}
void compute_prefix(int pos, int u, int v) {
  int k = K[u];
  for (int i = pos; i < s.size(); i++) {
    int &ret = dp[s[i] - 'a'][k + 1];
    if (ret != -2)
      k = ret;
    else {
      while (k >= 0 && s[k + 1] != s[i]) k = pi[k];
    }
    ret = k;
    if (s[k + 1] == s[i]) k++;
    pi[i] = k;
    if (k == need) {
      ANS++;
      k = pi[k];
    }
  }
  K[v] = k;
  return;
}
void modfiy(int len, int u, int v) {
  compute_prefix(s.length() - len, u, v);
  return;
}
void dfs(int u, int p) {
  for (auto v : adj[u]) {
    if (v.first == p) continue;
    int len = (int)v.second.length();
    s += v.second;
    modfiy(len, u, v.first);
    dfs(v.first, u);
  }
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    scanf("%s", al);
    adj[i].push_back({x, string(al)});
    adj[x].push_back({i, string(al)});
  }
  scanf("%s", al);
  s = string(al);
  need = s.length() - 1;
  s += '#';
  pi = vector<int>(N - 1, -1);
  K = vector<int>(N - 1, -1);
  for (int j = 0; j < 26; j++)
    for (int i = 0; i < N; i++) dp[j][i] = -2;
  pre(1, 0, 1);
  dfs(1, 0);
  printf("%lld\n", ANS);
}
