#include <bits/stdc++.h>
using namespace std;
long long counter = 0;
int substrLen;
string str;
vector<int> pi(300005);
struct path {
  int next;
  string str;
};
vector<vector<path>> graf;
void Prefix_Function(int startpos) {
  int len = str.length();
  for (int i = startpos; i < len; ++i) {
    int k = pi[i - 1];
  beg:
    if (str[i] == str[k])
      pi[i] = k + 1;
    else if (k == 0)
      pi[i] = 0;
    else {
      k = pi[k - 1];
      goto beg;
    }
    if (pi[i] == substrLen) counter++;
  }
}
void rec(int vertex) {
  for (int i = 0; i < graf[vertex].size(); ++i) {
    int start = str.size();
    str += graf[vertex][i].str;
    Prefix_Function(start);
    rec(graf[vertex][i].next);
    str.erase(str.end() - graf[vertex][i].str.size(), str.end());
  }
}
int main() {
  int n;
  cin >> n;
  graf.resize(n);
  for (int i = 1; i < n; ++i) {
    int tmpI;
    string tmpStr;
    cin >> tmpI >> tmpStr;
    path tmpPath;
    tmpPath.next = i;
    tmpPath.str = tmpStr;
    graf[tmpI - 1].push_back(tmpPath);
  }
  string subStr;
  cin >> subStr;
  substrLen = subStr.length();
  pi.push_back(0);
  str = subStr + "#";
  pi[0] = 0;
  Prefix_Function(1);
  rec(0);
  cout << counter;
  return 0;
}
