#include <bits/stdc++.h>
using namespace std;
const int BASE = 27LL;
const int M = 1e9 + 7;
const int N = 1e5 + 10;
struct node {
  int x;
  string s;
  node(int y) { x = y; }
};
int n, x, ln, len[N], ans;
long long h, p;
char s[N];
char out[4 * N];
vector<vector<node> > arr;
long long MOD(long long x) { return (x % M + M) % M; }
long long power(long long base, int exp) {
  long long res = 1;
  while (exp) {
    if (exp & 1) res = (res * base) % M;
    exp >>= 1;
    base = (base * base) % M;
  }
  return res;
}
void dfs(int x, long long val = 0, int cnt = 0, int k = 0) {
  for (size_t i = 0; i < arr[x].size(); ++i) {
    int y = arr[x][i].x;
    int tmp = cnt;
    int _k = k;
    long long _val = val;
    for (int j = 0; j < len[y]; ++j) {
      if (tmp >= ln) _val = MOD(_val - (p * (out[_k++] - 'a' + 1)) % M);
      _val = (_val * BASE + (arr[x][i].s[j] - 'a' + 1)) % M;
      out[tmp++] = arr[x][i].s[j];
      ans += (_val == h);
    }
    dfs(y, _val, tmp, _k);
  }
}
int main() {
  scanf("%d", &n);
  arr.clear();
  arr.resize(n + 1);
  for (int i = 2; i <= n; ++i) {
    scanf("%d", &x);
    arr[x].push_back(node(i));
    cin >> arr[x].back().s;
    len[i] = arr[x].back().s.size();
  }
  scanf(" %s", s);
  ln = strlen(s);
  for (int i = 0; i < ln; ++i) h = (h * BASE + s[i] - 'a' + 1) % M;
  p = power(BASE, ln - 1);
  dfs(1);
  printf("%d\n", ans);
  return 0;
}
