#include <bits/stdc++.h>
using namespace std;
const int max_n = 100000, alpha = 256;
struct pair_l {
  int num;
  string s;
  pair_l *nt;
} * nodes[max_n];
int n, bingo;
int aut[alpha][max_n * 2];
long long amt = 0;
int automa(int c, int state) { return aut[c][state]; }
void build_aut() {
  string t;
  cin >> t;
  t += char(0);
  int size = t.length();
  bingo = size - 1;
  int pi[size];
  pi[0] = 0;
  for (int i = 1; i < size; ++i) {
    int j = pi[i - 1];
    while (j > 0 && t[i] != t[j]) {
      j = pi[j - 1];
    }
    pi[i] = j + (t[i] == t[j]);
  }
  for (int i = 0; i < size; ++i) {
    for (int c = 0; c < alpha; ++c) {
      if (i > 0 && c != t[i]) {
        aut[c][i] = aut[c][pi[i - 1]];
      } else {
        aut[c][i] = i + (c == t[i]);
      }
    }
  }
}
void kill_aut() {}
void cnt(int pos, int state) {
  int curn, mst = state;
  pair_l *cur = nodes[pos];
  while (cur) {
    state = mst;
    curn = cur->s.length();
    for (int i = 0; i < curn; ++i) {
      amt += ((state = automa(cur->s[i], state)) == bingo);
    }
    if (nodes[cur->num]) {
      cnt(cur->num, state);
    }
    cur = cur->nt;
  }
}
void show_aut() {
  cout << "  ";
  for (int i = 'a' - 1; i < 'z' + 1; ++i) {
    cout.width(2);
    cout << char(i);
  }
  cout << endl;
  for (int i = 0; i <= bingo; ++i) {
    cout.width(2);
    cout << i;
    for (int j = 0; j < alpha; ++j) {
      cout.width(2);
      cout << aut[j][i];
    }
    cout << endl;
  }
}
int main() {
  int par;
  pair_l *cur, *tmp;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    nodes[i] = NULL;
  }
  for (int i = 1; i < n; ++i) {
    cin >> par;
    --par;
    if (!nodes[par]) {
      nodes[par] = new pair_l;
      nodes[par]->nt = NULL;
      nodes[par]->num = i;
      cin >> nodes[par]->s;
    } else {
      cur = new pair_l;
      cur->nt = nodes[par];
      cur->num = i;
      cin >> cur->s;
      nodes[par] = cur;
    }
  }
  build_aut();
  cnt(0, 0);
  cout << amt << endl;
  kill_aut();
  for (int i = 0; i < n; ++i) {
    cur = nodes[i];
    if (cur) {
      tmp = cur;
      cur = cur->nt;
      delete tmp;
    }
  }
  return 0;
}
