#include <bits/stdc++.h>
const double PI = acos(-1.0);
using namespace std;
int setb(int n, int pos) { return n = n | (1 << pos); }
int resb(int n, int pos) { return n = n & ~(1 << pos); }
bool checkb(long long n, long long pos) { return (bool)(n & (1ll << pos)); }
long long bigmod(long long b, long long p, long long m) {
  if (p == 0) return 1;
  long long ret = bigmod(b, p / 2, m);
  ret = (ret * ret) % m;
  if (p & 1) ret = (ret * b) % m;
  return ret;
}
int n;
string patt, str[300005];
int lps[300005], nxt[26][300005];
vector<int> g[300005];
vector<string> cost[300005];
int par[300005];
void build_lps() {
  int len = 0, i = 1;
  int l = patt.size();
  while (i < l) {
    for (int k = 0; k < 26; k++) {
      int cur = len;
      while (cur > 0 && ((patt[i] != patt[cur]) || (k + 'a') != patt[cur + 1]))
        cur = nxt[k][cur - 1];
      nxt[k][i] = (patt[i] == patt[cur] ? ++cur : 0);
    }
    while (patt[i] != patt[len] && len > 0) len = lps[len - 1];
    lps[i] = (patt[i] == patt[len] ? ++len : 0);
    i++;
  }
}
int ret;
int kmp(string text, int j) {
  int i = 0;
  while (i < text.size()) {
    while (text[i] != patt[j] && j > 0) j = nxt[text[i] - 'a'][j - 1];
    if (text[i] == patt[j]) j++;
    if (j == patt.size()) ret++, j = lps[j - 1];
    i++;
  }
  return j;
}
void dfs(int u, int j) {
  for (int k = 0; k < (int)g[u].size(); k++) {
    int keep = j;
    keep = kmp(cost[u][k], keep);
    dfs(g[u][k], keep);
  }
}
int main() {
  scanf("%d", &n);
  int i, p;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &p);
    cin >> str[i];
    g[p].push_back(i);
    cost[p].push_back(str[i]);
  }
  cin >> patt;
  build_lps();
  dfs(1, 0);
  printf("%d", ret);
  printf("\n");
  return 0;
}
