#include <bits/stdc++.h>
using namespace std;
const int Maxn = 500000, Maxm = 2500000, Mo = 1000000007, oo = INT_MAX;
int n, m, i, j, k, f, ans, len, nt[Maxn];
vector<int> e[Maxn];
string st[Maxn];
char fd[Maxn];
void dfs(int v, int j) {
  for (int i = 0; i < st[v].size(); i++) {
    while (j && st[v][i] != fd[j + 1]) j = nt[j];
    if (fd[j + 1] == st[v][i]) j++;
    if (j == len) ans++, j = nt[j];
  }
  for (int i = 0; i < e[v].size(); i++) dfs(e[v][i], j);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (i = 2; i <= n; i++) {
    cin >> f;
    e[f].push_back(i);
    cin >> st[i];
  }
  cin >> fd + 1;
  nt[1] = j = 0;
  len = strlen(fd + 1);
  for (i = 2; i <= len; i++) {
    while (j && fd[j + 1] != fd[i]) j = nt[j];
    if (fd[j + 1] == fd[i]) j++;
    nt[i] = j;
  }
  for (i = 0; i < e[1].size(); i++) dfs(e[1][i], 0);
  cout << ans << endl;
}
