#include <bits/stdc++.h>
using namespace std;
void compute_prefix_function(const string& s, vector<int>& p) {
  p.resize(s.size() + 1);
  p[0] = -1;
  int q = -1;
  for (size_t i = 1; i <= s.size(); ++i) {
    while (q >= 0 && s[q] != s[i - 1]) q = p[q];
    ++q;
    p[i] = q;
  }
}
vector<vector<int> > children;
vector<vector<string> > child_edges;
string needle;
vector<int> p;
vector<int> automaton[30];
int count(int v, int cur_q) {
  int res = 0;
  for (size_t i = 0; i < children[v].size(); ++i) {
    const string& s = child_edges[v][i];
    int q = cur_q;
    for (auto c = s.begin(); c != s.end(); ++c) {
      q = automaton[*c - 'a'][q];
      if (q == (int)needle.size()) {
        ++res;
        q = p[q];
      }
    }
    res += count(children[v][i], q);
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  children.resize(n);
  child_edges.resize(n);
  for (int i = 1; i < n; ++i) {
    int p;
    string s;
    cin >> p >> s;
    --p;
    children[p].push_back(i);
    child_edges[p].push_back(s);
  }
  cin >> needle;
  compute_prefix_function(needle, p);
  for (char c = 'a'; c <= 'z'; ++c) automaton[c - 'a'].resize(needle.size());
  for (size_t i = 0; i < needle.size(); ++i) {
    for (char c = 'a'; c <= 'z'; ++c) {
      int q = i;
      if (needle[q] == c)
        ++q;
      else if (q != 0)
        q = automaton[c - 'a'][p[q]];
      automaton[c - 'a'][i] = q;
    }
  }
  cout << count(0, 0) << endl;
  return 0;
}
