#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000 * 100 + 10;
string s[MAX], curr;
int glebokosc[3 * MAX];
vector<int> graf[MAX];
void licz() {
  glebokosc[0] = 0;
  int i = 0, j = 1;
  while (j < curr.size()) {
    if (curr[i] == curr[j]) {
      glebokosc[j] = i + 1;
      i++, j++;
    } else {
      if (i == 0) {
        glebokosc[j] = 0;
        j++;
      } else
        i = glebokosc[i - 1];
    }
  }
  for (int i = 1; i < curr.size(); i++) {
    while (glebokosc[i - 1] != 0 && curr[i] == curr[glebokosc[i - 1]])
      glebokosc[i - 1] = glebokosc[glebokosc[i - 1] - 1];
  }
}
int licznik = 0;
void dfs(int v, int jj) {
  int temp = jj;
  for (int i = 0; i < graf[v].size(); i++) {
    jj = temp;
    int akt = graf[v][i];
    for (int i = 0; i < (int)s[akt].size(); i++) {
      if (s[akt][i] == curr[jj]) {
        jj++;
        if (jj == curr.size()) {
          jj = glebokosc[jj - 1];
          licznik++;
        }
      } else {
        if (jj != 0) {
          jj = glebokosc[jj - 1];
          i--;
        }
      }
    }
    dfs(akt, jj);
  }
}
int n, p;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> p >> s[i];
    graf[p].push_back(i);
  }
  cin >> curr;
  licz();
  s[1] = "";
  dfs(1, 0);
  cout << licznik << endl;
}
