#include <bits/stdc++.h>   using namespace std;   long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }   long long lcm(long long a, long long b) { return a * b / GCD(a, b); }   int lb(int x) { return x & (-x); }   const long long N = 3e5 + 7;   const long long inf = 1e18 + 1;   const long long mod2 = 998244353;   const long long mod1 = 1e9 + 7;   const int P1 = 13331;   const int P2 = 131;   const double eps = 1e-6;   const double dbinf = 1e13 + 7;   const long long mod3 = 10000 + 7;   int n, m;   string s;   struct node {     int v, nxt;   };   node e[N];   int tot;   int head[N];   int ing[N];   int ans;   int dp[N][26];   void add(int u, int v) {     e[++tot] = {v, head[u]};     head[u] = tot;   }   void topsort(void) {     queue<int> q;     for (int i = 1; i <= n; i++) {       if (ing[i] == 0) {         q.push(i);         dp[i][s[i] -  a ] = 1;       }     }     int cnt = 0;     while (!q.empty()) {       int x = q.front();       cnt++;       q.pop();       for (int i = head[x]; i; i = e[i].nxt) {         int v = e[i].v;         if (--ing[v] == 0) q.push(v);         for (int j = 0; j <= 25; j++) {           dp[v][j] = max(dp[v][j], dp[x][j] + (s[v] -  a  == j));         }       }     }     if (cnt != n) {       cout <<  -1 n ;     } else {       int maxn = 0;       for (int i = 1; i <= n; i++) {         for (int j = 0; j <= 25; j++) {           maxn = max(maxn, dp[i][j]);         }       }       cout << maxn <<   n ;     }   }   int main() {     memset(head, 0, sizeof head);     memset(ing, 0, sizeof ing);     cin >> n >> m;     cin >> s;     s =  *  + s;     tot = 0;     for (int i = 1, u = 1, v = 1; i <= m; i++) {       cin >> u >> v;       add(u, v);       ing[v]++;     }     topsort();     return 0;   }   