#include <bits/stdc++.h>
using namespace std;
int n, st[300005], ed[300005], ver[300005];
int rig = 1, sz[300005], spe[300005];
char c[300005];
vector<int> g1[100005], g[300005];
string s[100005], t;
unsigned long long hashVal[300005], target = 0, power = 1, ans = 0;
map<unsigned long long, int> num;
void setup() {
  cin >> n;
  int v;
  for (int i = 2; i <= n; i++) {
    cin >> v >> s[i];
    g1[v].push_back(i);
  }
  cin >> t;
}
void buildGraph(int u, int pos) {
  for (int i = 0; i <= int(g1[u].size()) - 1; i++) {
    int v = g1[u][i], last = pos;
    for (int j = 0; j <= int(s[v].size()) - 1; j++) {
      c[++rig] = s[v][j];
      g[last].push_back(rig);
      last = rig;
    }
    buildGraph(v, last);
  }
}
void dfs(int u) {
  st[u] = ++rig;
  ver[rig] = u;
  sz[u] = 1, spe[u] = 0;
  for (int i = 0; i <= int(g[u].size()) - 1; i++) {
    int v = g[u][i];
    hashVal[v] = hashVal[u] * 29 + c[v] - 'a' + 1;
    dfs(v);
    sz[u] += sz[v];
    if (sz[v] > sz[spe[u]]) spe[u] = v;
  }
  ed[u] = rig;
}
void dfs(int u, bool keep) {
  if (!spe[u]) {
    if (keep) num[hashVal[u]]++;
    return;
  }
  for (int i = 0; i <= int(g[u].size()) - 1; i++) {
    int v = g[u][i];
    if (v == spe[u]) continue;
    dfs(v, false);
  }
  dfs(spe[u], true);
  for (int i = 0; i <= int(g[u].size()) - 1; i++) {
    int v = g[u][i];
    if (v == spe[u]) continue;
    for (int t = st[v]; t <= ed[v]; t++) num[hashVal[ver[t]]]++;
  }
  unsigned long long require = hashVal[u] * power + target;
  ans += num[require];
  if (keep)
    num[hashVal[u]]++;
  else
    for (int t = st[u] + 1; t <= ed[u]; t++) num[hashVal[ver[t]]]--;
}
void xuly() {
  buildGraph(1, 1), rig = 0;
  for (int i = 0; i <= int(t.size()) - 1; i++) {
    power *= 29;
    target = target * 29 + t[i] - 'a' + 1;
  }
  dfs(1);
  dfs(1, true);
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  xuly();
  return 0;
}
