#include <bits/stdc++.h>
using namespace std;
inline int setBit(int N, int pos) { return N = N | (1 << pos); }
inline int resetBit(int N, int pos) { return N = N & ~(1 << pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1 << pos)); }
const int MAX = 300005;
int n, lenPat, lps[MAX], ans, nxt[MAX][30];
char pat[MAX];
struct data {
  int pos, l;
  string s;
  data() {}
  data(int _pos, string _s) {
    pos = _pos;
    s = _s;
    l = (int)s.size();
  }
};
vector<data> graph[MAX];
void gen_lps() {
  int i, j, len;
  for (i = 1, len = 0, lps[0] = 0; i < lenPat;) {
    if (pat[i] == pat[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len == 0) {
        lps[i] = 0;
        i++;
      } else
        len = lps[len - 1];
    }
  }
  for (i = 0; i < lenPat; i++) {
    for (j = 0; j < 26; j++) {
      if (j == pat[i] - 'a')
        nxt[i][j] = i + 1;
      else if (j != pat[i] - 'a' && i - 1 >= 0)
        nxt[i][j] = nxt[lps[i - 1]][j];
    }
  }
}
int kmp(const char str[], int lenStr, int j) {
  int i;
  for (i = 0; i < lenStr; i++) {
    j = nxt[j][str[i] - 'a'];
    if (j == lenPat) {
      ans++;
      if (j) j = lps[j - 1];
    }
  }
  return j;
}
void dfs(int u, int par = -1, int idx = 0) {
  for (auto v : graph[u]) {
    if (v.pos != par) {
      dfs(v.pos, u, kmp(v.s.c_str(), v.l, idx));
    }
  }
}
int main() {
  int i, x;
  char temp[MAX];
  scanf("%d", &n);
  for (i = 1; i <= n - 1; i++) {
    scanf("%d", &x);
    scanf("%s", temp);
    graph[x - 1].push_back(data(i, temp));
  }
  scanf("%s", pat);
  lenPat = strlen(pat);
  gen_lps();
  dfs(0);
  printf("%d\n", ans);
  return 0;
}
