#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:536870912")
#pragma warning(disable : 4996)
using namespace std;
const int N = 1e5 + 100, M = 3e5 + 100, D = 26;
string s[N];
vector<int> v[N];
int p[M], go[M][D];
int ans = 0, len, t = 0, cl = 0;
char g[M], w[M];
void dfs(int node) {
  for (int i = 0; i < s[node].size(); i++) {
    p[t + i] = go[p[t + i - 1]][s[node][i] - 'a'];
    if (p[t + i] == len - 1) ans++;
  }
  t += s[node].size();
  for (int to : v[node]) dfs(to);
  t -= s[node].size();
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x;
    scanf("%d %s", &x, w);
    x--;
    int y = strlen(w);
    s[i].resize(y);
    for (int j = 0; j < y; j++) s[i][j] = w[j];
    v[x].push_back(i);
  }
  scanf(" %s", g);
  t = len = strlen(g);
  g[len++] = '#';
  t++;
  for (int i = 1; i < len; i++) {
    int j = p[i - 1];
    while (j > 0 && g[j] != g[i]) j = p[j - 1];
    if (g[j] == g[i]) j++;
    p[i] = j;
  }
  for (int i = 0; i <= len; i++) {
    for (int j = 0; j < D; j++) {
      if (g[i] == (j + 'a'))
        go[i][j] = i + 1;
      else if (i > 0)
        go[i][j] = go[p[i - 1]][j];
    }
  }
  dfs(0);
  printf("%d", ans);
  return 0;
}
