#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cout << *x, 0);
template <class c>
char dud(...);
struct debug {
  ~debug() { cout << endl; }
  template <class c>
  typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
    cout << boolalpha << i;
    return *this;
  }
  template <class c>
  typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
    return *this << range(begin(i), end(i));
  }
  template <class c, class b>
  debug& operator<<(pair<b, c> d) {
    return *this << "(" << d.first << ", " << d.second << ")";
  }
  template <class c>
  debug& operator<<(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    return *this << "]";
  }
};
long double eps = (long double)1 / 1e6;
const long double pi = 3.14159265359;
long long inf = 1e18, mod1 = 1e9 + 7;
long long sqr(long long a) { return a * a; }
long long qb(long long a) { return a * a * a; }
long long gcd(long long a, long long b) { return !a ? b : gcd(b % a, a); }
void binary(long long val, int to) {
  for (int i = 0; i < to; i++) cerr << ((1ll << i) & val ? 1 : 0);
  cerr << "\n";
}
long long binpow(long long a, long long b, long long mod) {
  return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod
                    : sqr(binpow(a, b / 2, mod)) % mod)
           : 1;
}
long long binmult(long long a, long long b, long long mod) {
  return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod
                    : (2 * binmult(a, b / 2, mod)) % mod)
           : 0;
}
const long long R = 1e4;
const long long tx[4] = {1, 0, -1, 0};
const long long ty[4] = {0, 1, 0, -1};
const char rev_to[4] = {'E', 'W', 'N', 'S'};
const int N = 3e5 + 1;
int M = 999999937;
const int POEBAT = 0;
const int pp = 73;
void bad() {
  cout << -1;
  exit(0);
}
int n, m, need, how, pr[N], piz[N];
string second[N], t;
vector<int> h, g[N];
long long ans = 0;
void dfs(int v, int p, bool keep) {
  for (int i = 0; i < (long long)second[v].size(); i++) {
    h.push_back((h.back() + 1ll * (second[v][i] - 'a' + 1) * piz[how]) % M);
    how++;
    if ((long long)h.size() > (long long)t.size()) {
      int x = need,
          y = (h.back() - (h[(long long)h.size() - (long long)t.size() - 1]) +
               M) %
              M;
      x = (1ll * x * piz[(long long)h.size() - (long long)t.size() - 1]) % M;
      if (x == y) ans++;
    }
  }
  for (auto& z : g[v]) {
    if (z == p) continue;
    dfs(z, v, POEBAT);
  }
  for (int i = 0; i < (long long)second[v].size(); i++) {
    h.pop_back();
    how--;
  }
}
bool is_prime(int val) {
  for (int i = 2; i <= sqrt(val); i++)
    if (val % i == 0) return 0;
  return 1;
}
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  cin >> n;
  piz[0] = 1;
  for (int i = 1; i < N; i++) piz[i] = (1ll * piz[i - 1] * pp) % M;
  second[0] = "";
  h.push_back(0);
  for (int i = 1; i < n; i++) {
    cin >> pr[i] >> second[i];
    pr[i]--;
    if (pr[i] != -1) g[pr[i]].push_back(i);
  }
  cin >> t;
  for (int i = 0; i < (long long)t.size(); i++) {
    need = (need + 1ll * (t[i] - 'a' + 1) * piz[i]) % M;
  }
  pr[0] = -1;
  for (int i = 0; i < n; i++) {
    if (pr[i] == -1) {
      dfs(i, i, POEBAT);
    }
  }
  cout << ans;
  return 0;
}
