#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater() {}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) { cout << x; }
void __print(long x) { cout << x; }
void __print(long long x) { cout << x; }
void __print(unsigned x) { cout << x; }
void __print(unsigned long x) { cout << x; }
void __print(unsigned long long x) { cout << x; }
void __print(float x) { cout << x; }
void __print(double x) { cout << x; }
void __print(long double x) { cout << x; }
void __print(char x) { cout << '\'' << x << '\''; }
void __print(const char *x) { cout << '\"' << x << '\"'; }
void __print(const string &x) { cout << '\"' << x << '\"'; }
void __print(bool x) { cout << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cout << '{';
  __print(x.first);
  cout << ',';
  __print(x.second);
  cout << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cout << '{';
  for (auto &i : x) cout << (f++ ? "," : ""), __print(i);
  cout << "}";
}
void _print() { cout << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cout << ", ";
  _print(v...);
}
long long p = 1e9 + 7;
const int N = 1e5 + 5;
int n;
vector<int> g[N];
vector<string> a(N);
vector<int> lps(N);
int ans = 0;
string t;
int FT[N][26];
void dfs(int r, int p, int last) {
  int val = 0;
  if (p != -1) {
    string s;
    s = a[r];
    int j = last;
    for (int i = 0; i < ((int)(s).size()); ++i) {
      if (s[i] == t[j]) {
        j++;
        if (j == (int)(t).size()) {
          ans++;
          j = FT[j - 2][s[i] - 'a'];
        }
      } else if (j > 0) {
        j = FT[j - 1][s[i] - 'a'];
      }
    }
    val = j;
  }
  for (auto j : g[r]) {
    if (j == p) continue;
    dfs(j, r, val);
  }
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  ;
  int T = 1;
  while (T--) {
    cin >> n;
    for (int i = 0; i < (n - 1); ++i) {
      int u;
      cin >> u;
      cin >> a[i + 2];
      g[u].push_back(i + 2);
      g[i + 2].push_back(u);
    }
    cin >> t;
    int m = (int)(t).size();
    for (int i = 1; i <= (m - 1); ++i) {
      int j = lps[i - 1];
      while (j >= 0) {
        if (t[j] == t[i]) {
          lps[i] = j + 1;
          break;
        }
        if (j < 1) break;
        j = lps[j - 1];
      }
    }
    for (int i = 0; i <= (m - 1); ++i) {
      int x = t[lps[i]] - 'a';
      for (int j = 0; j < 26; j++) {
        if (x == j) {
          FT[i][j] = lps[i] + 1;
        } else if (lps[i] == 0) {
          FT[i][j] = 0;
        } else {
          FT[i][j] = FT[lps[i] - 1][j];
        }
      }
    }
    dfs(1, -1, 0);
    cout << ans;
  }
  timecalculater();
  return 0;
}
