#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, _nxt[N][30], accept, ans;
vector<char> sigma;
vector<pair<int, string> > child[N];
string t;
void dfs(int, int);
int read(int, string);
int &dfa(int, char);
int32_t main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int pv;
    string edge;
    cin >> pv >> edge;
    pv--;
    child[pv].push_back({i, edge});
  }
  cin >> t;
  for (char c = 'a'; c <= 'z'; c++) sigma.push_back(c);
  for (char c : sigma) dfa(0, c) = 0;
  dfa(0, t[0]) = 1;
  int par = 0;
  for (int state = 1; state <= t.size(); state++) {
    for (char c : sigma) dfa(state, c) = dfa(par, c);
    if (state < t.size()) {
      dfa(state, t[state]) = state + 1;
      par = dfa(par, t[state]);
    }
  }
  accept = t.size();
  dfs(0, 0);
  cout << ans << endl;
}
void dfs(int v, int dfa_pos) {
  for (auto [u, s] : child[v]) dfs(u, read(dfa_pos, s));
}
int read(int pos, string str) {
  for (char c : str) {
    pos = dfa(pos, c);
    if (pos == accept) ans++;
  }
  return pos;
}
int &dfa(int state, char edge) { return _nxt[state][int(edge - 'a')]; }
