#include <bits/stdc++.h>
using namespace std;
void run();
int main() {
  ios::sync_with_stdio(0);
  run();
}
string word;
long long kmp[600002];
long long res = 0;
vector<int> edge[600002];
string sledge[600002];
void dfs(int x, int state = 0) {
  for (char c : sledge[x]) {
    while (state and (state == word.size() or word[state] != c)) {
      state = kmp[state];
    }
    if (word[state] == c) {
      ++state;
    }
    if (state == word.size()) ++res;
  }
  for (int y : edge[x]) {
    dfs(y, state);
  }
}
void run() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x;
    cin >> x >> sledge[i];
    --x;
    edge[x].push_back(i);
  }
  cin >> word;
  for (int i = 2; i <= word.size(); i++) {
    kmp[i] = kmp[i - 1];
    while (kmp[i] and word[kmp[i]] != word[i - 1]) kmp[i] = kmp[kmp[i]];
    if (word[kmp[i]] == word[i - 1]) ++kmp[i];
  }
  dfs(0);
  cout << res << endl;
}
