func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 300100;   int n, m, a[maxn], ans = -1;   int f[maxn][30], du[maxn], Time;   char s[maxn];   int dfn[maxn], low[maxn];   vector<int> g[maxn];   vector<int>::iterator it;   bool loop = 0, in[maxn];   stack<int> q;   void dfs(int x) {     dfn[x] = low[x] = ++Time;     in[x] = 1;     q.push(x);     for (int i = 0; i < g[x].size(); ++i) {       int k = g[x][i];       if (!dfn[k]) {         dfs(k);         low[x] = min(low[x], low[k]);       } else if (in[k] && dfn[k] < low[x]) {         low[x] = min(low[x], dfn[k]);       }       for (int j = 0; j < 26; ++j) {         f[x][j] = max(f[x][j], f[k][j]);       }     }     if (dfn[x] == low[x]) {       int cnt = 0;       while (1) {         int tem = q.top();         q.pop();         cnt++;         in[tem] = 0;         if (tem == x) break;       }       if (cnt > 1) loop = 1;     }     ++f[x][a[x]];   }   int main() {     scanf( %d%d , &n, &m);     scanf( %s , s + 1);     for (int i = 1; i <= n; ++i) {       a[i] = s[i] -  a ;     }     for (int i = 1, x, y; i <= m; ++i) {       scanf( %d%d , &x, &y);       if (x == y) loop = 1;       g[x].push_back(y), du[y]++;     }     if (loop) {       printf( -1 n );       return 0;     }     for (int i = 1; i <= n; ++i) {       if (!du[i]) {         dfs(i);         if (loop == 1) {           printf( -1 n );           return 0;         }         for (int j = 0; j < 26; ++j) {           ans = max(f[i][j], ans);         }       }     }     printf( %d n , ans);     return 0;   }   