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.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class D {
	
	public static final int unvisited = 0, visiting = 1, visited = 2;

	public static boolean dfs(int node, ArrayList<HashSet<Integer>> adj, int[] state){
		state[node] = visiting;

		for(final int next : adj.get(node)){
			if(state[next] == unvisited){
				if(!dfs(next, adj, state)){ //
					state[node] = visited; return false;
				}
			}else if(state[next] == visiting){ //cycle!
				return false;
			}
		}

		state[node] = visited;
		return true;
	}

	public static boolean find_cycle(final int N, ArrayList<HashSet<Integer>> adj){
		int[] state = new int[N];
		for(int i = 0; i < N; i++){ state[i] = unvisited; }
		for(int i = 0; i < N; i++){
			if(state[i] == unvisited){
				if(!dfs(i, adj, state)){
					return true;
				}
			}
		}
		return false;
	}
	
	public static int topological_sort(final int N, int[] types, ArrayList<HashSet<Integer>> adj, int[] in_degs){
		LinkedList<Integer> queue = new LinkedList<Integer>();
		int[] degs = new int[N];
		int[][] result = new int[N][26];
		
		System.arraycopy(in_degs, 0, degs, 0, N);
		
		int max = 0;
		for(int node = 0; node < N; node++){
			if(degs[node] != 0){ continue; }
			
			queue.add(node);
			result[node][types[node]] = 1;
			max = 1;
		}
		
		while(!queue.isEmpty()){
			final int node = queue.poll();
			
			for(final int next : adj.get(node)){
				for(int type = 0; type < 26; type++){
					result[next][type] = Math.max(result[next][type], result[node][type] + (types[next] == type ? 1 : 0));
					max = Math.max(max, result[next][type]);
				}
				
				degs[next]--;
				if(degs[next] == 0){ queue.add(next); }
			}
		}
		
		return max;
	}
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			
			int[] types = new int[n];
			{
				final char[] ins = sc.next().toCharArray();
				for(int i = 0; i < n; i++){
					types[i] = ins[i] - 'a';
				}
			}
			
			ArrayList<HashSet<Integer>> adj = new ArrayList<HashSet<Integer>>();
			for(int i = 0; i < n; i++){ adj.add(new HashSet<Integer>()); }
			
			int[] in_degs = new int[n];
			for(int i = 0; i < m; i++){ 
				final int s = sc.nextInt() - 1;
				final int t = sc.nextInt() - 1;
				
				if(!adj.get(s).contains(t)){
					adj.get(s).add(t);
					in_degs[t]++;
				}
			}
			
			if(find_cycle(n, adj)){ 
				System.out.println(-1);
				return;
			}
			
			System.out.println(topological_sort(n, types, adj, in_degs));
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}