#include <bits/stdc++.h>
using namespace std;
template <class T, class L>
bool smax(T &x, L y) {
  return x < y ? (x = y, 1) : 0;
}
template <class T, class L>
bool smin(T &x, L y) {
  return y < x ? (x = y, 1) : 0;
}
const int maxn = 3e5 + 17, z = 26;
int n, f[maxn], nxt[maxn][z], ans;
string p, s[maxn];
vector<int> g[maxn];
void dfs(int v = 0, int ptr = 0) {
  for (auto u : g[v]) {
    int k = ptr;
    for (auto c : s[u]) {
      k = nxt[k][c - 'a'];
      if (k == p.size()) ans++, k = f[k];
    }
    dfs(u, k);
  }
}
int main() {
  cin >> n;
  for (int i = 1, p; i < n; i++) cin >> p >> s[i], g[p - 1].push_back(i);
  cin >> p;
  int k = 0;
  for (int i = 1; i < p.size(); i++) {
    while (k && p[i] != p[k]) k = f[k];
    if (p[i] == p[k]) k++;
    f[i + 1] = k;
  }
  for (int i = 0; i < p.size(); i++)
    for (int j = 0; j < z; j++)
      nxt[i][j] = p[i] - 'a' == j ? i + 1 : bool(i) * nxt[f[i]][j];
  dfs();
  cout << ans << '\n';
  return 0;
}
