#include <bits/stdc++.h>
using namespace std;
int pi[300005];
string pattern;
void getPi() {
  pi[0] = -1;
  for (int i = 1; i < pattern.size(); ++i) {
    pi[i] = pi[i - 1];
    while (pi[i] >= 0 && pattern[pi[i] + 1] != pattern[i]) pi[i] = pi[pi[i]];
    if (pattern[pi[i] + 1] == pattern[i]) ++pi[i];
  }
}
vector<vector<pair<int, string> > > grafo;
int n;
int cont = 0;
void dfs(int p, int k) {
  int i, v, K = k;
  for (v = 0; v < grafo[p].size(); v++) {
    k = K;
    string text = grafo[p][v].second;
    for (int i = 0; i < text.size(); ++i) {
      while (k >= 0 && pattern[k + 1] != text[i]) k = pi[k];
      if (pattern[k + 1] == text[i]) ++k;
      if (k + 1 == pattern.size()) {
        cont++;
        k = pi[k];
      }
    }
    dfs(grafo[p][v].first, k);
  }
}
int main() {
  int i, s, t;
  string rotulo;
  scanf("%d", &n);
  grafo.resize(n);
  for (i = 0; i < n - 1; i++) {
    scanf("%d", &t);
    cin >> rotulo;
    s = i + 1;
    t--;
    grafo[t].push_back(make_pair(s, rotulo));
  }
  cin >> pattern;
  getPi();
  dfs(0, -1);
  cout << cont;
  return 0;
}
