#include <bits/stdc++.h>
using namespace std;
const long long maxn = 300100, mod = 1e9 + 7, maxa = 3e6 + 100, maxb = 23,
                base = 3079, base2 = 3079, mod2 = 1e9 + 9;
const long long inf = 2e18 + 13;
long long max(long long x, long long y) { return (x > y ? x : y); }
long long min(long long x, long long y) { return (x < y ? x : y); }
vector<long long> v[maxn];
vector<long long> dat[maxn];
vector<long long> t1[maxn];
long long h[maxn];
long long par[maxn][23];
char c[maxn];
bool mark[maxn];
bool visited[maxn];
long long ans = 0, m, thash;
string t;
long long bp[maxn];
void predfs(long long x) {
  mark[x] = 1;
  for (long long i = 0; i < v[x].size(); i++) {
    long long u = v[x][i];
    if (!mark[u]) {
      h[u] = h[x] + 1;
      par[u][0] = x;
      for (long long j = 1; j < maxb; j++) {
        par[u][j] = par[par[u][j - 1]][j - 1];
      }
      predfs(u);
    }
  }
}
long long parent(long long x, long long p) {
  for (long long i = 0; i < maxb; i++) {
    if ((p >> i) & 1) {
      x = par[x][i];
    }
  }
  return x;
}
void dfs(long long x, long long _hash) {
  visited[x] = 1;
  _hash = _hash * base + (long long)c[x];
  _hash %= mod;
  if (h[x] > m) {
    long long pr = parent(x, m);
    _hash -= ((long long)c[pr] * bp[m]) % mod;
    _hash += (5 * mod);
    _hash %= mod;
  }
  if (_hash == thash) {
    ans++;
  }
  for (long long i = 0; i < v[x].size(); i++) {
    long long u = v[x][i];
    if (!visited[u]) {
      dfs(u, _hash);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, x = 0;
  bp[0] = 1;
  for (long long i = 1; i < maxn; i++) {
    bp[i] = (bp[i - 1] * base) % mod;
  }
  c[0] = '2';
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long a;
    string b;
    cin >> a >> b;
    a--;
    dat[a].push_back(i + 1);
    for (long long j = 0; j < b.size(); j++) {
      x++;
      c[x] = b[j];
      t1[i + 1].push_back(x);
      if (j) {
        v[x].push_back(x - 1);
        v[x - 1].push_back(x);
      }
    }
  }
  for (long long i = 0; i < dat[0].size(); i++) {
    long long u = t1[dat[0][i]][0];
    v[0].push_back(u);
    v[u].push_back(0);
  }
  for (long long i = 1; i < n; i++) {
    long long x = t1[i].back();
    for (long long j = 0; j < dat[i].size(); j++) {
      long long f = dat[i][j];
      long long u = t1[f][0];
      v[x].push_back(u);
      v[u].push_back(x);
    }
  }
  h[0] = 1;
  predfs(0);
  cin >> t;
  m = t.size();
  thash = 0;
  for (long long i = 0; i < m; i++) {
    thash *= base;
    thash += t[i];
    thash %= mod;
  }
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}
