#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> adj[100005];
char data[3 * 100005];
int starts[100005];
int lens[100005];
char t[100005];
int len_t;
int zfn[100005];
void kmpPreprocess() {
  int i = 0, j = -1;
  zfn[0] = -1;
  while (i < len_t) {
    while (j >= 0 && t[i] != t[j]) j = zfn[j];
    i++;
    j++;
    zfn[i] = j;
  }
}
int curLen;
char *curStr;
int numOccs = 0;
int kmp(int kmpJ) {
  int i = 0;
  while (i < curLen) {
    while (kmpJ >= 0 && curStr[i] != t[kmpJ]) kmpJ = zfn[kmpJ];
    i++;
    kmpJ++;
    if (kmpJ == len_t) {
      numOccs++;
      kmpJ = zfn[kmpJ];
    }
  }
  return kmpJ;
}
void dfs(int n, int kmpJ) {
  int adj_len = adj[n].size();
  for (int i = 0; i < adj_len; i++) {
    int c = adj[n][i];
    curStr = data + starts[c];
    curLen = lens[c];
    int newKmpJ = kmp(kmpJ);
    dfs(c, newKmpJ);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  int offset = 0, p;
  for (int i = 1; i < N; i++) {
    cin >> p;
    adj[p].push_back(i + 1);
    starts[i + 1] = offset;
    cin.ignore();
    cin.getline(data + offset, 100005);
    lens[i + 1] = cin.gcount() - 1;
    offset += lens[i + 1];
  }
  cin.getline(t, 100005);
  len_t = cin.gcount() - 1;
  kmpPreprocess();
  dfs(1, 0);
  cout << numOccs << "\n";
  return 0;
}
