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.io.*;
import java.util.*;
import java.math.BigInteger; 

public class test {
    
    
   static class sort implements Comparator<int[]>//
   {
        public int compare(int[] a,int[] b)
        {
            //if(a[0] == b[0]) return a[1]-b[1];
           return a[0]-b[0];
        }
   }
   public static void pr(PrintWriter out,Object o)
   {
      
    out.println(o.toString());out.flush();
    
   }
   public static void prW(PrintWriter out,Object o)
   {
      
    out.print(o.toString());out.flush();
    
   }
   public static int intIn(String st)
   {
      return Integer.parseInt(st);
   }
   
   
    
    public static void pr(Object o)
    {
        System.out.println(o.toString());
    }
    public static void prW(Object o)
    {
        System.out.print(o.toString());
    }
    
   
    public static int inInt(String s)
    {
        return Integer.parseInt(s);
    }
    public static long in(String s)
    {
        return Long.parseLong(s);
    }

    
    
    static int[] toIntArray(String[] m) 
    { 
        int[] p=new int[m.length];
        for(int o=0;o<m.length;o++)
        {
            p[o]= inInt(m[o]);
        }
        return p;
    }
    static long[] toLArray(String[] m) 
    { 
       long[] p=new long[m.length];
        for(int o=0;o<m.length;o++)
        {
            p[o]= in(m[o]);
        }
        return p;
    }
    public static boolean G(int i,int[] vis,List<List<Integer>> l)
    {
        vis[i]=1;

        boolean bol=false;
        for(int x : l.get(i))
        {
            if(vis[x] == 1)
            {
                bol=true;
            }
            else if(vis[x]==0)
            {
                bol=(bol || G(x,vis,l));
            }
        }

        vis[i]=2;
        return bol;
    }
    public static int F(int i,List<List<Integer>> l,char[] arr,Integer[][] dp)
    {
        //vis[i]=1;
        int o=arr[i]-'a';
        if(dp[o][i] != null) return dp[o][i];
        int v=0;
        //if((arr[i]-'a') == o) v++;
        for(int x : l.get(i))
        {
           //if(vis[x]==0)
            {
                F(x,l,arr,dp);
            }
        }
        for(int j=0;j<26;j++)
        {
            //if(j==o) dp[j][i]=0;
            //else
            {

                if(dp[j][i] == null) dp[j][i]=0;;;
            }
        }
        for(int x : l.get(i))
        {
           //if(vis[x]==0)
            {
                for(int j=0;j<26;j++)
                {
                    dp[j][i]=Math.max(dp[j][i],dp[j][x]);
                }
            }
        }

        dp[o][i]+=1;
        
       
        //if((arr[i]-'a') == o) v++;
        return dp[o][i];
        
    }
    public static String[] F(BufferedReader bf) throws Exception
    {
        return (bf.readLine().split(" "));
    }
    
    public static void main (String[] args) throws Exception {
        
        BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);;;
        
        //int[] map=new int[1000001];
      
        int y=1;//Integer.parseInt(bf.readLine());
        
        for(int w=0;w<y;w++)
        {

            
    
            String[] xlp = bf.readLine().split(" ");
            
            int n,k,t,h;//boolean bol=false;
           int m;
           //boolean
            n=inInt(xlp[0]);m=inInt(xlp[1]);//k=inInt(xlp[2]);
            boolean[] il = new boolean[26];
             char[] arr = bf.readLine().toCharArray();
             List<List<Integer>> list=new ArrayList<>();
            // List<Set<Integer>> list=new ArrayList<>();
             for(char ch : arr) il[ch-'a']=true;
             for(int o=0;o<n;o++) list.add(new ArrayList<>());

                for(int o=0;o<m;o++)
                {
                    int[] tem = toIntArray(F(bf));
                    list.get(tem[0]-1).add(tem[1]-1);
                }
                int[] vis=new int[n];boolean bol=false;
                for(int o=0;o<vis.length;o++)
                {
                    if(vis[o]==0)
                    {
                        if(G(o,vis,list)) 
                        {
                            bol=true;break;
                        }
                    }
                }

                if(bol){ pr(out,-1);continue;}
                int ans=0;Integer[][] dp = new Integer[26][n];
                
                
                for(int o=0;o<n;o++) F(o,list,arr,dp);   
               for(int o=0;o<26;o++)
                {
                    if(!il[o]) continue;
                    int res=0;
                    
                    for(int x=0;x<n;x++)
                    {
                        
                        ans=Math.max(ans,dp[o][x]);
                    }

                    //if(res > ans) ans=res;    
                }
                pr(out,ans);
            
          
           
            

            

            
            
            
        }
        out.close();

    }
}


/*
1
7
8 4 7 -2 20 30 -3
1 2
1 3
3 4 
4 5
4 6
3 7

1
5
8 4 7 -2 
1 2
1 3
3 4 
4 5



100663319,201326611,402653189,805306457,1610612741
Kickstart
String rp;
            rp = "Case #"+(w+1)+": "+(n-ans)+" ";
            if(curr == max) rp=rp +"INDEFINITELY";
            else rp = rp+(curr);
static int[][] dir={{0,1},{1,0},{-1,0},{0,-1}};

static class SegmentTreeRMQ 
    { 
    int st[]; 
    int minVal(int x, int y) { 
        return (x > y) ? x : y; 
    } 
  
    
    int getMid(int s, int e) { 
        return s + (e - s) / 2; 
    } 
  
    
    int RMQUtil(int ss, int se, int qs, int qe, int index) 
    { 
        
        if (qs <= ss && qe >= se) 
            return st[index]; 
  
        // If segment of this node is outside the given range 
        if (se < qs || ss > qe) 
            return Integer.MIN_VALUE; 
  
        // If a part of this segment overlaps with the given range 
        int mid = getMid(ss, se); 
        return minVal(RMQUtil(ss, mid, qs, qe, 2 * index + 1), 
                RMQUtil(mid + 1, se, qs, qe, 2 * index + 2)); 
    } 
  
    // Return minimum of elements in range from index qs (query 
    // start) to qe (query end).  It mainly uses RMQUtil() 
    int RMQ(int n, int qs, int qe) 
    { 
        // Check for erroneous input values 
        
  
        return RMQUtil(0, n - 1, qs, qe, 0); 
    } 
  
    // A recursive function that constructs Segment Tree for 
    // array[ss..se]. si is index of current node in segment tree st 
    int constructSTUtil(int arr[], int ss, int se, int si) 
    { 
        // If there is one element in array, store it in current 
        //  node of segment tree and return 
        if (ss == se) { 
            st[si] = arr[ss]; 
            return arr[ss]; 
        } 
  
        // If there are more than one elements, then recur for left and 
        // right subtrees and store the minimum of two values in this node 
        int mid = getMid(ss, se); 
        st[si] = minVal(constructSTUtil(arr, ss, mid, si * 2 + 1), 
                constructSTUtil(arr, mid + 1, se, si * 2 + 2)); 
        return st[si]; 
    } 
  
    
    void con(int arr[]) 
    { 
        // Allocate memory for segment tree 
  
        //Height of segment tree 
        int n = (arr.length);
        int x = (int) (Math.ceil(Math.log(n) / Math.log(2))); 
  
        //Maximum size of segment tree 
        int max_size = 2 * (int) Math.pow(2, x) - 1; 
        st = new int[max_size]; // allocate memory 
  
        // Fill the allocated memory st 
        constructSTUtil(arr, 0, n - 1, 0); 
    }
    }
     static class DSU {
    
    int[] p;int[] sz;int op;int c;;
    int[] last;
    public void G(int n)
    {
        last=new int[n];
        p=new int[n];
        sz=new int[n];c=n;
        op=n;
        for(int h=0;h<n;h++)
        {
            sz[h]=1;p[h]=h;
            last[h]=h;
        }
    }
    public int find(int x)
    {
        int y=x;
        while(x!=p[x]) x=p[x];
        while(y!=p[y])
        {
            int tem=p[y];
            p[y]=x;y=tem;
        }
        return p[y];
    }
    public void union(int a,int b)
    {
        int x,y;
        x=find(a);y=find(b);
        if(x==y) return;
        if(sz[x]>sz[y])
        {
            p[y] = x;
            sz[x]+=sz[y];
            last[x]=Math.max(last[x],last[y]);
        }
        else
        {
            p[x]=y;sz[y]+=sz[x];
            last[y]=Math.max(last[y],last[x]);
        }
        c--;
        
    }}

    static long pow(long x, long y, long p)
      {
        long res = 1; // Initialize result
     
        x = x % p; // Update x if it is more than or
        // equal to p
     
        if (x == 0)
          return 0l; // In case x is divisible by p;
     
        while (y > 0)
        {
     
          // If y is odd, multiply x with result
          if ((y & 1) != 0)
            res = (res * x) % p;
     
          // y must be even now
          y = y >> 1; // y = y/2
          x = (x * x) % p;
        }
        return res;
      }
      static long gcd(long a, long b)
        {
          if (b == 0)
            return a;
          return gcd(b, a % b); 
        }
        static int gcd(int a, int b,int o)
        {
          if (b == 0)
            return a;
          return gcd(b, a % b,o); 
        }
    
      
    

*/


