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.*;
import java.util.concurrent.*;

public final class substring
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	static int[] x,y,cnt,cnt2;
	static int[][] al,al2;
	static boolean ans=true;
	static boolean[] vis,in_stack;
	
	static List<Integer> topo_sort(int[][] al,int n)
	{
		int[] deg=new int[n];
		
		ArrayDeque<Integer> ad=new ArrayDeque<>();
		
		for(int i=0;i<n;i++)
		{	
			for(int x:al[i])
			{	
				deg[x]++;
			}
		}
		
		for(int i=0;i<n;i++)
		{
			if(deg[i]==0)
			{
				ad.add(i);
			}
		}
		
		List<Integer> list=new ArrayList<>();
		
		while(ad.size()>0)
		{
			int curr=ad.removeFirst();
			
			list.add(curr);
			
			for(int x:al[curr])
			{
				deg[x]--;
				
				if(deg[x]==0)
				{
					ad.add(x);
				}
			}
		}
		
		return list;
	}
	
	static void dfs(int u)
	{
		vis[u]=true;in_stack[u]=true;
		
		for(int x:al[u])
		{
			if(in_stack[x])
			{
				ans=false;return;
			}
			
			else if(!vis[x])
			{
				dfs(x);
			}
		}
		
		in_stack[u]=false;
	}
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt(),m=sc.nextInt();
		
		char[] a=sc.next().toCharArray();
		
		x=new int[m];y=new int[m];cnt=new int[n];cnt2=new int[n];
		
		for(int i=0;i<m;i++)
		{
			x[i]=sc.nextInt()-1;y[i]=sc.nextInt()-1;
			
			cnt[x[i]]++;cnt2[y[i]]++;
		}
		
		al=new int[n][];al2=new int[n][];
		
		for(int i=0;i<n;i++)
		{
			al[i]=new int[cnt[i]];cnt[i]=0;
			
			al2[i]=new int[cnt2[i]];cnt2[i]=0;
		}
		
		for(int i=0;i<m;i++)
		{
			int u=x[i],v=y[i];
			
			al[u][cnt[u]++]=v;
			
			al2[v][cnt2[v]++]=u;
		}
			
		vis=new boolean[n];in_stack=new boolean[n];
		
		for(int i=0;i<n;i++)
		{
			if(!vis[i])
			{
				dfs(i);
			}
		}
		
		if(ans)
		{
			List<Integer> topo=topo_sort(al,n);int max=0;
			
		//	out.println(topo);
			
			for(int i=0;i<26;i++)
			{
				int[] dp=new int[n];
				
				for(int j=0;j<n;j++)
				{
					int now=topo.get(j);
					
					if(a[now]-'a'==i)
					{
						dp[now]=1;
					}
					
					int curr=0;
					
					for(int x:al2[now])
					{
						curr=Math.max(curr,dp[x]);
					}
					
					dp[now]+=curr;max=Math.max(max,dp[now]);
				}
			}
			
			out.println(max);
		}
		
		else
		{
			out.println(-1);
		}
		
		out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}