#include <bits/stdc++.h>
const unsigned long long base = 19260817;
const int N = 3e5 + 7;
unsigned long long p[N], need;
std::vector<char> s[N];
std::vector<int> vec[N];
std::vector<unsigned long long> cur;
char t[N];
long long ans;
int len, n;
void dfs(int u) {
  for (int i = 0; i < s[u].size(); i++) {
    cur.push_back(cur.back() * base + s[u][i]);
    if (cur.size() > len) {
      unsigned long long x = cur.back() - cur[cur.size() - len - 1] * p[len];
      if (x == need) ans++;
    }
  }
  for (int v : vec[u]) dfs(v);
  for (int i = 0; i < s[u].size(); i++) cur.pop_back();
}
int main() {
  scanf("%d", &n);
  for (int i = p[0] = 1; i < N; i++) p[i] = p[i - 1] * base;
  for (int i = 2; i <= n; i++) {
    int u;
    scanf("%d%s", &u, t);
    vec[u].push_back(i);
    int len = strlen(t);
    for (int j = 0; j < len; j++) s[i].push_back(t[j]);
  }
  scanf("%s", t);
  len = strlen(t);
  for (int i = 0; i < len; i++) need = need * base + t[i];
  cur.push_back(0);
  dfs(1);
  printf("%lld\n", ans);
  return 0;
}
