#include <bits/stdc++.h>
using namespace std;
class sp {
 public:
  int q;
  sp *w;
  sp(int q1, sp *w1) {
    q = q1;
    w = w1;
  }
};
sp *a[100000];
int t = 0, y, f[300001];
char *s[100000], d[300001];
void l(int q, int e) {
  int w;
  sp *c;
  for (w = 0; s[q][w]; w++) {
    while ((e) && (d[e] != s[q][w])) e = f[e - 1];
    if (d[e] == s[q][w]) {
      e++;
      if (e == y) {
        t++;
        e = f[e - 1];
      }
    }
  }
  for (sp *c = a[q]; c; c = c->w) l(c->q, e);
}
int main() {
  int q, w, e, r;
  cin >> q;
  for (w = 0; w < q; w++) a[w] = 0;
  s[0] = new char[1];
  s[0][0] = 0;
  for (w = 1; w < q; w++) {
    scanf("%d%s", &e, d);
    a[e - 1] = new sp(w, a[e - 1]);
    r = strlen(d);
    s[w] = new char[r + 1];
    for (e = 0; e <= r; e++) s[w][e] = d[e];
  }
  scanf("%s", d);
  y = strlen(d);
  f[0] = 0;
  e = 0;
  for (w = 1; w < y; w++) {
    while ((e) && (d[e] != d[w])) e = f[e - 1];
    if (d[e] == d[w]) e++;
    f[w] = e;
  }
  l(0, 0);
  cout << t;
  return 0;
}
