#include <bits/stdc++.h>
using namespace std;
const int MX = 100005, INF = 1000000000, mod = 1000000009;
const long long int LINF = 1000000000000000000ll;
const double eps = 1e-9;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
char in[MX * 3];
int n, m;
vector<int> ch[MX];
vector<string> s[MX];
string t;
int l[MX * 3];
int dfs(int v, int p) {
  int res = 0, a;
  string u;
  for (int i = 0; i < ch[v].size(); i++) {
    a = p;
    u = s[v][i];
    for (int j = 0; j < u.size(); j++) {
      while (a != -1 && u[j] != t[a]) a = l[a];
      if (a == -1)
        a = 0;
      else
        a++;
      if (a == m) res++;
    }
    res += dfs(ch[v][i], a);
  }
  return res;
}
int main() {
  int a;
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d%s", &a, in);
    t = in;
    a--;
    ch[a].push_back(i);
    s[a].push_back(t);
  }
  scanf("%s", in);
  t = in;
  m = t.size();
  t += '*';
  l[0] = -1;
  l[1] = 0;
  for (int i = 2, j = 0; i <= m;) {
    if (t[i - 1] == t[j])
      l[i++] = ++j;
    else if (j == 0)
      l[i++] = 0;
    else
      j = l[j];
  }
  printf("%d\n", dfs(0, 0));
  return 0;
}
