#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5, M = 26 + 4;
int n, m, k, f[N], nxt[N][M];
vector<int> adj[N];
string s[N], t;
void dfs(int u, int p) {
  for (auto c : s[u]) {
    p = nxt[p][c - 'a'];
    k += (p == m);
  }
  for (auto v : adj[u]) dfs(v, p);
}
inline void build_KMP() {
  for (int i = 1, p = 0; i < m; i++) {
    while (p && t[i] ^ t[p]) p = f[p];
    p += (t[i] == t[p]);
    f[i + 1] = p;
  }
  for (int i = 0; i <= m; i++)
    for (int j = 0; j < 26; j++)
      if (i < m && t[i] == 'a' + j)
        nxt[i][j] = i + 1;
      else
        nxt[i][j] = nxt[f[i]][j];
}
inline void read_input() {
  cin >> n;
  for (int u = 1; u < n; u++) {
    int v;
    cin >> v >> s[u];
    adj[--v].push_back(u);
  }
  cin >> t;
  m = t.size();
}
inline void solve() {
  build_KMP();
  dfs(0, 0);
  cout << k;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read_input(), solve();
  return 0;
}
