#include <bits/stdc++.h>
using namespace std;
const int maxN = 500 * 1000 + 5;
const int maxL = 20;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long P = 4447;
pair<int, long long> par[maxN][maxL];
vector<pair<int, int> > adj[maxN];
long long pw[maxN];
int lvl[maxN];
long long Add(long long x, long long y) { return (x + y) % mod; }
long long Mull(long long x, long long y) { return (x * y) % mod; }
void dfs(int x) {
  for (int i = 1; i < maxL; i++) {
    int y = par[x][i - 1].first;
    long long num = Add(par[x][i - 1].second,
                        Mull(pw[(1 << (i - 1))], par[y][i - 1].second));
    par[x][i] = make_pair(par[y][i - 1].first, num);
  }
  for (int i = 0; i < ((int)(adj[x]).size()); i++) {
    int u = adj[x][i].first;
    if (u == par[x][0].first) continue;
    par[u][0] = make_pair(x, adj[x][i].second);
    lvl[u] = lvl[x] + 1;
    dfs(u);
  }
}
pair<int, long long> getpar(int x, int k) {
  long long sum = 0;
  int ind = 0;
  for (int i = maxL - 1; i >= 0; i--) {
    if ((1 << i) <= k) {
      sum = Add(sum, Mull(pw[ind], par[x][i].second));
      ind += (1 << i);
      x = par[x][i].first;
      k -= (1 << i);
    }
  }
  return make_pair(x, sum);
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int n1 = n;
  for (int i = 1; i < n1; i++) {
    int pr;
    string s;
    cin >> pr >> s;
    pr--;
    for (int j = 0; j < ((int)(s).size()) - 1; j++) {
      adj[pr].push_back(make_pair(n, s[j] - 'a'));
      adj[n].push_back(make_pair(pr, s[j] - 'a'));
      pr = n;
      n++;
    }
    adj[pr].push_back(make_pair(i, s[((int)(s).size()) - 1] - 'a'));
    adj[i].push_back(make_pair(pr, s[((int)(s).size()) - 1] - 'a'));
  }
  string t;
  cin >> t;
  pw[0] = 1;
  for (int i = 1; i < maxN; i++) pw[i] = Mull(pw[i - 1], P);
  dfs(0);
  reverse(t.begin(), t.end());
  long long hash = 0;
  for (int i = 0; i < ((int)(t).size()); i++)
    hash = Add(hash, Mull(pw[i], t[i] - 'a'));
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (lvl[i] < ((int)(t).size())) continue;
    pair<int, long long> x = getpar(i, ((int)(t).size()));
    if (x.second == hash) ans++;
  }
  cout << ans << endl;
  return 0;
}
