#include <bits/stdc++.h>
using namespace std;
int n, res, m;
string s[300005];
vector<int> adj[300005];
struct vertex {
  map<char, int> next, go;
  int p, link;
  char pch;
  vector<int> leaf;
  vertex(int p = -1, char pch = -1) : p(p), pch(pch), link(-1) {}
};
vector<vertex> t;
void aho_init() {
  t.clear();
  t.push_back(vertex());
}
void add_string(string &s, int id) {
  int v = 0;
  for (char c : s) {
    if (!t[v].next.count(c)) {
      t[v].next[c] = t.size();
      t.push_back(vertex(v, c));
    }
    v = t[v].next[c];
  }
  t[v].leaf.push_back(id);
}
int go(int v, char c);
int get_link(int v) {
  if (t[v].link < 0)
    if (!v || !t[v].p)
      t[v].link = 0;
    else
      t[v].link = go(get_link(t[v].p), t[v].pch);
  return t[v].link;
}
int go(int v, char c) {
  if (!t[v].go.count(c))
    if (t[v].next.count(c))
      t[v].go[c] = t[v].next[c];
    else
      t[v].go[c] = v == 0 ? 0 : go(get_link(v), c);
  return t[v].go[c];
}
int match(string &tex, int st) {
  int j = st;
  for (auto ss : tex) {
    j = go(j, ss);
    if (j == m) res++, j = get_link(j);
  }
  return j;
}
void dfs(int u, int st) {
  for (auto v : adj[u]) {
    int j = match(s[v], st);
    dfs(v, j);
  }
}
int main() {
  cin >> n;
  for (int i = 1, u; i < n; i++) {
    cin >> u >> s[i];
    u--;
    adj[u].push_back(i);
  }
  string pat;
  cin >> pat;
  m = pat.size();
  aho_init();
  add_string(pat, 0);
  dfs(0, 0);
  cout << res << endl;
  return 0;
}
