#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long BIG = 1446803456761533460LL;
const int Big = 336860180;
const long long int INF = LONG_LONG_MAX;
const vector<vector<long long int>> adj4({{0, 1}, {0, -1}, {1, 0}, {-1, 0}});
const vector<vector<long long int>> adj8(
    {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, -1}, {1, -1}, {-1, 1}, {1, 1}});
long long int clk_ar[10];
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int powMod(long long int a, long long int b, long long int mod) {
  long long int n = 1;
  long long int p = a;
  while (b > 0) {
    if (b % 2 == 1) {
      n *= p;
      n %= mod;
    }
    p *= p;
    p %= mod;
    b /= 2;
  }
  return n;
}
long long int modularInverse(long long int a, long long int mod) {
  return powMod(a, mod - 2, mod);
}
long long int binarysearch(long long int l, long long int r,
                           bool (*bsfunction)(long long int)) {
  while (r - l > 1) {
    long long int mid = (l + r) / 2;
    bool val = bsfunction(mid);
    if (val) {
      r = mid;
    } else {
      l = mid;
    }
  }
  return l;
}
stringstream sss;
const long long int maxn = 100010;
const long long int maxc = 300010;
vector<pair<long long int, string>> g[maxn];
string T;
long long int Tn;
long long int F[maxc];
long long int calc[maxc][26];
long long int cnt = 0;
void dfs(long long int x, long long int fval) {
  for (auto y : g[x]) {
    long long int f = fval;
    for (auto c : y.second) {
      f = calc[f][c - 'a'];
      if (f == Tn - 1) ++cnt;
    }
    dfs(y.first, f);
  }
}
void MAIN() {
  long long int n;
  cin >> n;
  for (long long int i = 0; i < (n - 1); ++i) {
    long long int p;
    string s;
    cin >> p >> s;
    --p;
    g[p].push_back({i + 1, s});
  }
  cin >> T;
  T += '#';
  Tn = T.size();
  F[0] = 0;
  for (long long int i = (1); i < (Tn); ++i) {
    long long int j = F[i - 1];
    while (j > 0 && T[i] != T[j]) {
      j = F[j - 1];
    }
    if (T[i] == T[j]) ++j;
    F[i] = j;
  }
  calc[0][T[0] - 'a'] = 1;
  for (long long int i = (1); i < (Tn); ++i) {
    for (long long int j = 0; j < (26); ++j) {
      calc[i][j] = ((T[i] - 'a') == j) ? i + 1 : calc[F[i - 1]][j];
    }
  }
  dfs(0, 0);
  cout << (cnt) << '\n';
}
long long int TESTCASEN = 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  sss << R"(
7
1 ab
5 bacaba
1 abacaba
2 aca
5 ba
2 ba
aba
    )";
  for (long long int test = 0; test < (TESTCASEN); ++test) {
    MAIN();
  }
  return 0;
}
