#include <bits/stdc++.h>
using namespace std;
class KMP {
  int reset[300010];
  string w;

 public:
  KMP() {}
  void Build(const string& x) {
    w = x;
    reset[0] = -1;
    for (int i = 1; i < (int)w.size(); i++) {
      int j = reset[i - 1];
      while (j >= 0 && w[j + 1] != w[i]) j = reset[j];
      if (w[j + 1] == w[i]) ++j;
      reset[i] = j;
    }
  }
  int Go(int pos, char l) {
    int j = pos;
    while (j >= 0 && w[j + 1] != l) j = reset[j];
    if (w[j + 1] == l) ++j;
    return j;
  }
};
struct arco {
  int verso;
  string p;
  arco() : verso(0) {}
  arco(int n, string x) : verso(n), p(x) {}
};
int N;
vector<arco> colleg[300010];
string pattern;
char buf[300010];
KMP Macchina;
long long ris;
void Dfs(int n, int stato) {
  for (auto i : colleg[n]) {
    int j = stato;
    for (auto k : i.p) {
      j = Macchina.Go(j, k);
      if (j == (int)pattern.size() - 1) ++ris;
    }
    Dfs(i.verso, j);
  }
}
int main() {
  scanf("%d", &N);
  int a;
  string appo;
  for (int i = 1; i < N; i++) {
    scanf("%d %s", &a, buf);
    appo = buf;
    colleg[a].emplace_back(arco(i + 1, appo));
  }
  scanf("%s", buf);
  pattern = buf;
  Macchina.Build(pattern);
  Dfs(1, -1);
  printf("%lld\n", ris);
  return 0;
}
