You are given a graph with n nodes and m directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the most frequently occurring letter. For example, if letters on a path are "abaca", then the value of that path is 3. Your task is find a path whose value is the largest.

Input

The first line contains two positive integers n, m (1 ≤ n, m ≤ 300 000), denoting that the graph has n nodes and m directed edges.

The second line contains a string s with only lowercase English letters. The i-th character is the letter assigned to the i-th node.

Then m lines follow. Each line contains two integers x, y (1 ≤ x, y ≤ n), describing a directed edge from x to y. Note that x can be equal to y and there can be multiple edges between x and y. Also the graph can be not connected.

Output

Output a single line with a single integer denoting the largest value. If the value can be arbitrarily large, output -1 instead.

Examples

Input

5 4
abaca
1 2
1 3
3 4
4 5


Output

3


Input

6 6
xzyabc
1 2
3 1
2 3
5 4
4 3
6 4


Output

-1


Input

10 14
xzyzyzyzqx
1 2
2 4
3 5
4 5
2 6
6 8
6 5
2 10
3 9
10 9
4 6
1 10
2 8
3 7


Output

4

Note

In the first sample, the path with largest value is 1 → 3 → 4 → 5. The value is 3 because the letter 'a' appears 3 times.
import java.util.*;
import java.io.*;

public class Substring {
    
    
    
    /************************ SOLUTION STARTS HERE ************************/
    
    static int adj[][];
    private static boolean visitedGlobal[];
    private static boolean visitedTemp[];

    private static boolean dfs(int u){

        visitedGlobal[u] = true;
        visitedTemp[u] = true;
        for(int v:adj[u]){

            if(visitedTemp[v])
                return true;

            if(!visitedGlobal[v]){
                if(dfs(v))
                    return true;
            }

        }
        visitedTemp[u] = false;
        return false;

    }

    private static boolean isCyclic(int V){

        for(int i=1;i<=V;i++){

            if(!visitedGlobal[i]){      
                if(dfs(i))
                    return true;
            }

        }

        return false;

    }
    
    static int memo[];
    static char str[];
    
    static int topDown(int u, char alph) {
        memo[u] = 0;
        for(int v : adj[u])
            memo[u] = Math.max(memo[u] , memo[v] == -1 ? topDown(v, alph) : memo[v]);
        
        memo[u] += str[u - 1] == alph ? 1 : 0;
        return memo[u];
    }
    
    // Courtesy : UWI ( adjacency list using Jagged Arrays )
    static int[][] packD(int n, int[] from, int[] to , int isOneBased) {   
        int[][] g = new int[n + isOneBased][];
        int[] p = new int[n + isOneBased];
        for (int f : from)
            p[f]++;
        for (int i = 0 + isOneBased; i < n + isOneBased; i++)
            g[i] = new int[p[i]];
        for (int i = 0; i < from.length; i++) 
            g[from[i]][--p[from[i]]] = to[i];

        return g;
    }
    
    private static void solve(){

        int V = nextInt();
        int E = nextInt();
        
        str = nextLine().toCharArray();
        
        visitedGlobal = new boolean[V + 1];
        visitedTemp = new boolean[V + 1];
        
        int from[] = new int[E];
        int to[] = new int[E];
        
        while(E-->0) {
            int u = nextInt();
            int v = nextInt();
            from[E] = v;
            to[E] = u;
        }
        
        adj = packD(V, from, to, 1);
        
        if(isCyclic(V)) {
            println(-1);
            return;
        }
        
        // Now a DAG
        memo = new int[V + 1];
        int max = 0;
        for(char ch = 'a'; ch <= 'z'; ch++) {
            Arrays.fill(memo, -1);
            for(int i = 1; i <= V; i++) {
                if(memo[i] == -1)
                    topDown(i, ch);
                max = Math.max(max , memo[i]);
            }
        }
        
        println(max);
        
    }
        
    
    /************************ SOLUTION ENDS HERE ************************/
    
    
    
    
    
    /************************ TEMPLATE STARTS HERE **********************/
    
    /* Increase stack size in java

     */
    public static void main(String[] args) throws IOException {
        new Thread(null, new Runnable() {
            public void run() {
                new Substring().run();
            }
        }, "Increase Stack", 1 << 25).start();

    }

    void run(){ 
        reader = new BufferedReader(new InputStreamReader(System.in));
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
        st     = null;
        solve();
        try {
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        writer.close();
    }
    
    static BufferedReader reader;
    static PrintWriter    writer;
    static StringTokenizer st;
    
    static String next()
    {while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}            
    st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
    static String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}             
    static int    nextInt()   {return Integer.parseInt(next());}
    static long   nextLong()  {return Long.parseLong(next());}     
    static double nextDouble(){return Double.parseDouble(next());}
    static char   nextChar()  {return next().charAt(0);}
    static int[]  nextIntArray(int n)         {int[] a= new int[n];   int i=0;while(i<n){a[i++]=nextInt();}  return a;}
    static long[] nextLongArray(int n)        {long[]a= new long[n];  int i=0;while(i<n){a[i++]=nextLong();} return a;}    
    static int[]  nextIntArrayOneBased(int n) {int[] a= new int[n+1]; int i=1;while(i<=n){a[i++]=nextInt();} return a;}            
    static long[] nextLongArrayOneBased(int n){long[]a= new long[n+1];int i=1;while(i<=n){a[i++]=nextLong();}return a;}            
    static void   print(Object o)  { writer.print(o);  }
    static void   println(Object o){ writer.println(o);}
    
    /************************ TEMPLATE ENDS HERE ************************/
    
}