#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:167772160")
const int INF = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.);
char str[600600];
int p[600600];
int l = 0;
int patlen = 0;
int ans = 0;
void add(char c) {
  str[l] = c;
  int pos = l;
  ++l;
  if (pos == 0) {
    p[pos] = 0;
    return;
  }
  int j = p[pos - 1];
  while (j > 0 && str[pos] != str[j]) j = p[j - 1];
  if (str[pos] == str[j]) ++j;
  p[pos] = j;
  if (j >= patlen) ++ans;
}
vector<int> G[100500];
string S[100500];
char buff[500500];
void dfs(int v) {
  for (int i = 0; i < G[v].size(); ++i) {
    int nxt = G[v][i];
    for (int j = 0; j < S[nxt].length(); ++j) {
      add(S[nxt][j]);
    }
    dfs(nxt);
    l -= S[nxt].length();
  }
}
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i < N; ++i) {
    int p;
    scanf("%d %s", &p, buff);
    --p;
    G[p].push_back(i);
    S[i] = buff;
  }
  scanf("%s", buff);
  int len = strlen(buff);
  patlen = len;
  for (int i = 0; i < len; ++i) add(buff[i]);
  add('$');
  dfs(0);
  printf("%d\n", ans);
  return 0;
}
