#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void maximize(T &lhs, U rhs) {
  if (lhs < rhs) lhs = rhs;
}
template <class T, class U>
void minimize(T &lhs, U rhs) {
  if (lhs > rhs) lhs = rhs;
}
template <class T, class U>
void maximize(T &lhs, const initializer_list<U> &rhs) {
  U max_rhs = max(rhs);
  if (lhs < max_rhs) {
    lhs = max_rhs;
  }
}
template <class T, class U>
void minimize(T &lhs, const initializer_list<U> &rhs) {
  U min_rhs = min(rhs);
  if (lhs > min_rhs) {
    lhs = min_rhs;
  }
}
template <class T>
T tabs(T x) {
  return (x < (T)0 ? -x : x);
}
namespace Task {
const int N = 3e5 + 333;
const int maxC = 26;
vector<pair<int, string> > adj[N / 3];
string t;
int n, lenT;
vector<vector<int> > aut;
vector<int> kmp;
long long ans = 0;
void buildAutomaton(const string &str) {
  kmp.resize(lenT + 2, 0);
  for (int i = 1; i < lenT; ++i) {
    int j = kmp[i - 1];
    while (j > 0 and str[j] != str[i]) {
      j = kmp[j - 1];
    }
    kmp[i] = j + (str[j] == str[i]);
  }
  aut.resize(lenT + 2, vector<int>(maxC + 1, 0));
  for (int i = 0; i <= lenT; ++i) {
    for (int c = 0; c < maxC; ++c) {
      if (i > 0 and c != str[i] - 'a') {
        aut[i][c] = aut[kmp[i - 1]][c];
      } else {
        aut[i][c] = i + (c == str[i] - 'a');
      }
    }
  }
}
void dfs(int u, int lps) {
  for (auto [v, s] : adj[u]) {
    int cur = lps;
    for (char c : s) {
      cur = aut[cur][c - 'a'];
      if (cur == lenT) {
        ++ans;
      }
    }
    dfs(v, cur);
  }
}
void solve() {
  cin >> n;
  for (int i = 2; i <= n; ++i) {
    int p;
    string s;
    cin >> p >> s;
    adj[p].emplace_back(make_pair(i, s));
  }
  cin >> t;
  lenT = (int)((t).size());
  buildAutomaton(t + "#");
  dfs(1, 0);
  cout << ans << '\n';
}
}  // namespace Task
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  Task::solve();
}
