#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T maxer(T &a, T b) {
  a = max(a, b);
}
template <typename T>
inline T miner(T &a, T b) {
  a = min(a, b);
}
void iOS() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void fin() { freopen("in", "r", stdin); }
void fout() { freopen("out", "w", stdout); }
const int inf = ~0u / 10;
const long long linf = ~0ull / 2;
const int maxn = 3e5 + 20, base = 709;
vector<pair<int, string> > adj[maxn];
long long ans = 0;
int b[maxn], h[maxn], hp, past = 0;
string t;
void dfs(int v) {
  for (auto x : adj[v]) {
    for (int i = 1; i <= x.second.size(); i++)
      h[past] = h[past - 1] * base + x.second[i - 1], past++;
    for (int i = past - x.second.size() - t.size(); i + t.size() <= past; i++)
      if (h[i + t.size()] - (h[i] * b[t.size()]) == hp) ans++;
    dfs(x.first);
    for (int i = past - x.second.size() + 1; i <= past; i++) h[i] = 0;
    past -= x.second.size();
  }
}
int main() {
  iOS();
  b[0] = 1;
  for (int i = 1; i < maxn; i++) b[i] = b[i - 1] * base;
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x;
    string s;
    cin >> x >> s;
    x--;
    adj[x].push_back(make_pair(i, s));
  }
  cin >> t;
  for (int i = 0; i < t.size(); i++) hp = hp * base + t[i];
  dfs(0);
  cout << ans;
  return 0;
}
