func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   const int M1 = 1000000007;   const int M2 = 1000000087;   int N;   int H1[310000];   int P1[310000];   int H2[310000];   int P2[310000];   int HH1, HH2;   int n, m;   vector<int> g[100007];   string s[100007];   char t[300007];   int ans;   void precalc() {     H1[0] = H2[0] = 0;     P1[0] = P2[0] = 1;     for (int i = 1; i < 300007; i++) {       P1[i] = (P1[i - 1] * 31LL) % M1;       P2[i] = (P2[i - 1] * 37LL) % M2;     }     for (int i = 0, _n = (m); i < _n; ++i) {       char c = t[i] -  a  + 1;       HH1 = (HH1 * 31LL + c) % M1;       HH2 = (HH2 * 37LL + c) % M2;     }   }   void addChar(char c) {     c = c -  a  + 1;     H1[N + 1] = (H1[N] * 31LL + c) % M1;     H2[N + 1] = (H2[N] * 37LL + c) % M2;     N++;   }   bool isTail() {     if (N < m) return false;     int r = N - 1;     int l = r - m + 1;     int CH1 = H1[r + 1] - ((long long)H1[l] * P1[r - l + 1]) % M1;     if (CH1 < 0) CH1 += M1;     int CH2 = H2[r + 1] - ((long long)H2[l] * P2[r - l + 1]) % M2;     if (CH2 < 0) CH2 += M2;     return CH1 == HH1 && CH2 == HH2;   }   void dfs(int v) {     for (int i = 0, _n = ((int)((s[v]).size())); i < _n; ++i) {       addChar(s[v][i]);       ans += isTail();     }     for (int i = 0, _n = ((int)((g[v]).size())); i < _n; ++i) dfs(g[v][i]);     N -= (int)((s[v]).size());   }   void solution() {     scanf( %d n , &n);     for (int i = 0, _n = (n - 1); i < _n; ++i) {       int p;       scanf( %d %s n , &p, t);       s[i + 1] = string(t);       g[p - 1].push_back(i + 1);     }     m = strlen(gets(t));     precalc();     dfs(0);     printf( %d n , ans);   }   int main() {     solution();     return 0;   }   