#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005, MAXC = 300005;
int start[MAXN], len[MAXN], preKmp[MAXC];
char s[MAXC], t[MAXC];
vector<int> adj[MAXN];
int n, m, lenT, res;
void buildKmp() {
  lenT = strlen(t);
  preKmp[0] = 0;
  for (int i = 1, j = 0; i < lenT; i++) {
    while (j && t[i] != t[j]) j = preKmp[j - 1];
    if (t[i] == t[j]) j++;
    preKmp[i] = j;
  }
}
void dfs(int u, int state) {
  for (size_t i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    int j, _state;
    for (j = start[v], _state = state; j < start[v] + len[v]; j++) {
      while (_state && s[j] != t[_state]) _state = preKmp[_state - 1];
      if (s[j] == t[_state]) _state++;
      if (_state == lenT) res++, _state = preKmp[_state - 1];
    }
    dfs(v, _state);
  }
}
void solve() {
  buildKmp();
  dfs(1, 0);
  printf("%d\n", res);
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int x;
    char c;
    scanf("%d ", &x);
    adj[x].push_back(i);
    start[i] = m;
    while (scanf("%c", &c) && c != '\n') {
      s[m++] = c;
      len[i]++;
    }
  }
  scanf("%s\n", t);
  solve();
  return 0;
}
