#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
const int nmax = 300300;
int n, val, res;
string s[nmax];
int p[nmax];
vector<int> g[nmax];
int f[nmax], nxt[nmax][27];
char cur[nmax];
char buf[nmax];
void add(int n, char ch) {
  cur[n] = ch;
  if (n == 0)
    f[n] = 0;
  else
    f[n] = nxt[n - 1][ch - 'a'];
  if (f[n] == val) res++;
  for (int i = 0; i < 27; i++)
    if (cur[f[n]] == 'a' + i)
      nxt[n][i] = f[n] + 1;
    else if (f[n] != 0)
      nxt[n][i] = nxt[f[n] - 1][i];
    else
      nxt[n][i] = 0;
}
void go(int v, int n) {
  for (int i = 0; i < (int)(s[v].size()); i++) {
    add(n, s[v][i]);
    n++;
  }
  for (int i = 0; i < (int)(g[v].size()); i++) go(g[v][i], n);
}
int main() {
  cin >> n;
  for (int i = 0; i < (int)(n - 1); i++) {
    scanf("%d", &p[i + 1]);
    p[i + 1]--;
    g[p[i + 1]].push_back(i + 1);
    scanf("%s", buf);
    s[i + 1] = buf;
  }
  scanf("%s", buf);
  s[0] = buf;
  char now = 'z' + 1;
  s[0] += now;
  val = s[0].size() - 1;
  go(0, 0);
  cout << res << endl;
  return 0;
}
