#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:128000000")
const int lim = 100100;
const long long pr = 57;
int n;
int predict[lim];
string s[lim];
string p;
long long hp;
vector<int>* v;
int col[lim];
int cur_col = 1;
long long answer = 0;
long long deg[lim + lim + lim];
long long h[lim + lim + lim];
map<pair<int, int>, int> getor;
void createDeg() {
  deg[0] = 1;
  for (int i = 1; i < lim + lim + lim; i++) deg[i] = deg[i - 1] * pr;
  for (int i = 0; i < p.size(); i++) hp = hp + p[i] * deg[i];
}
void input() {
  v = new vector<int>[lim];
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> predict[i];
    cin >> s[i];
    v[i].push_back(predict[i]);
    v[predict[i]].push_back(i);
    getor[make_pair(min(i, predict[i]), max(i, predict[i]))] = i;
  }
  cin >> p;
}
void clever_dfs(int num, int sz, int viewed = 0) {
  if (col[num] == cur_col) return;
  col[num] = cur_col;
  if (sz - viewed >= p.size()) {
    for (; sz - viewed >= p.size(); viewed++) {
      long long hs = h[viewed + p.size() - 1];
      if (viewed) hs = hs - h[viewed - 1];
      if (hs == hp * deg[viewed]) answer++;
    }
  }
  for (int i = 0; i < v[num].size(); i++) {
    int to = v[num][i];
    if (col[to] == cur_col) continue;
    int ind = getor[make_pair(min(num, to), max(num, to))];
    for (int j = 0; j < s[ind].size(); j++) {
      h[sz + j] = s[ind][j] * deg[sz + j];
      if (sz + j) h[sz + j] += h[sz + j - 1];
    }
    clever_dfs(to, sz + s[ind].size(), viewed);
  }
}
int main() {
  input();
  createDeg();
  clever_dfs(1, 0);
  cout << answer << endl;
  return 0;
}
