#include <bits/stdc++.h>
using namespace std;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
int GETi() {
  int i;
  scanf("%d", &i);
  return i;
}
template <class T>
T sqr(T val) {
  return val * val;
}
int N;
vector<int> E[100001];
string P[100001];
int L[100001];
string T;
signed long long TH, THL;
char buf[400005];
char Ts[400005];
signed long long mo = 1000000007;
signed long long dfs(int cur, int TL, signed long long hash) {
  signed long long res = 0;
  int i, x;
  int NL = TL + P[cur].size();
  strcpy(buf + TL, P[cur].c_str());
  for (i = 0; i < P[cur].size(); i++) {
    hash = (hash * 256 + buf[TL + i]) % mo;
    if (TL + i >= T.size())
      hash = (((hash - THL * buf[TL + i - T.size()]) % mo) + mo) % mo;
    if (hash == TH && TL + i + 1 >= T.size()) {
      res++;
    }
  }
  for (i = 0; i < E[cur].size(); i++) {
    res += dfs(E[cur][i], NL, hash);
    buf[NL] = 0;
  }
  return res;
}
int comp(int cur) {
  int i, r;
  L[cur] = 0;
  for (i = 0; i < E[cur].size(); i++) {
    E[cur][i] = comp(E[cur][i]);
    L[cur] = max(L[cur], L[E[cur][i]]);
  }
  if (E[cur].size() == 1) {
    P[E[cur][0]] = P[cur] + P[E[cur][0]];
    P[cur] = "";
    return E[cur][0];
  } else {
    return cur;
  }
}
void solve() {
  int f, r, i, j, k, l, x, y;
  int ma = 0;
  N = GETi();
  for (i = 0; i < N - 1; i++) {
    cin >> j >> P[i + 2];
    E[j].push_back(i + 2);
  }
  cin >> T;
  strcpy(Ts, T.c_str());
  TH = 0;
  THL = 1;
  for (i = 0; i < T.size(); i++) {
    TH = (TH * 256 + T[i]) % mo;
    THL = (THL * 256) % mo;
  }
  cout << dfs(1, 0, 0) << endl;
  return;
}
int main(int argc, char** argv) {
  if (argc > 1) freopen(argv[1], "r", stdin);
  solve();
  return 0;
}
