#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
int zfn[100010];
int count = 0, nodes_count;
string P, T;
vector<string> str;
vector<vector<int> > connections;
void kmpPreprocess() {
  int i = 0, j = -1;
  zfn[0] = -1;
  while (i < P.size()) {
    while (j >= 0 && P[i] != P[j]) j = zfn[j];
    i++;
    j++;
    zfn[i] = j;
  }
}
void kmp_DFS(int current, int j) {
  string T = str[current];
  int i = 0;
  while (i < T.size()) {
    while (j >= 0 && T[i] != P[j]) j = zfn[j];
    i++;
    j++;
    if (j == P.size()) {
      count++;
      j = zfn[j];
    }
  }
  for (vector<int>::iterator it = connections.at(current).begin();
       it != connections.at(current).end(); ++it) {
    kmp_DFS(*it, j);
  }
}
int main() {
  cin.sync_with_stdio(false);
  cin >> nodes_count;
  str.resize(nodes_count + 1);
  for (int i = 0; i < nodes_count; i++) {
    vector<int> v;
    connections.push_back(v);
  }
  int current_parent;
  for (int current_node = 0; current_node < nodes_count - 1; current_node++) {
    T = "";
    cin >> current_parent >> T;
    connections[current_parent - 1].push_back(current_node + 1);
    str.at(current_node + 1) = T;
  }
  cin >> P;
  kmpPreprocess();
  T = "";
  kmp_DFS(0, 0);
  cout << count << endl;
  return 0;
}
