#include <bits/stdc++.h>
using namespace std;
const int MAXn = 3e5 + 10;
long long nxt[MAXn][26 + 10], n, hp[MAXn], salar, ans, hp2;
vector<pair<int, string> > g[MAXn];
string s;
void dfs(int a) {
  for (int i = 0; i < g[a].size(); i++) {
    string s1 = g[a][i].second;
    int node = g[a][i].first, salar2 = salar;
    for (int j = 0; j < s1.size(); j++) {
      salar = nxt[salar][s1[j] - 'a'];
      if (salar == s.size()) ans++;
    }
    dfs(node);
    salar = salar2;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int u;
    string s1;
    cin >> u >> s1;
    g[u].push_back(pair<int, string>(i, s1));
  }
  cin >> s;
  hp[0] = hp[1] = 0;
  for (int i = 1; i < s.size(); i++) {
    while (hp2 > 0 && s[hp2] != s[i]) hp2 = hp[hp2];
    if (s[i] == s[hp2]) hp2++;
    hp[i + 1] = hp2;
  }
  nxt[0][(s[0] - 'a')] = 1;
  for (int i = 1; i <= s.size(); i++)
    for (int j = 0; j < 26; j++) {
      if (i < s.size() && s[i] - 'a' == j)
        nxt[i][j] = i + 1;
      else
        nxt[i][j] = nxt[hp[i]][j];
    }
  dfs(1);
  cout << ans;
}
