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.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;


import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.TreeSet;


public final class CF_460_D{

	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}


	static long mod=1000000007;
	static long MX=1000000000000000001L;

	// Global vars
	static BufferedWriter out;
	static InputReader reader;





	static void process() throws Exception {


		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader=new InputReader(System.in);



		int n=reader.readInt();

		ArrayList<Integer>[] friends;
		TreeSet<Integer>[] tfriends;

		ArrayList<Integer>[] ancs;

		//ancs=new ArrayList[n];
		friends=new ArrayList[n];
		tfriends=new TreeSet[n];


		for (int i=0;i<n;i++){
			tfriends[i]=new TreeSet<Integer>();

			friends[i]=new ArrayList<Integer>();
			//ancs[i]=new ArrayList<Integer>();
		}

		int m=reader.readInt();
		String s=reader.readString();
		int ans=-1;
		int[] nancs=new int[n];
		boolean skip=false;
		for (int i=0;i<m;i++){
			int u=reader.readInt()-1;
			int v=reader.readInt()-1;
			tfriends[u].add(v);
			//ancs[v].add(u);
			nancs[v]++;
			if (u==v)
				skip=true;

		}
		for (int i=0;i<n;i++)
			friends[i].addAll(tfriends[i]);

		if (!skip){

			int[] stack=new int[n];
			int time=1;
			//int[] visited=new int[n];

			int CX=26;
			int[][] best=new int[n][CX];
			int[] onstack=new int[n];
			int[] cur=new int[n];
			boolean[] processed=new boolean[n];
			int st=0;
			boolean some=false;
			loop:for (int i=0;i<n;i++){
				if (nancs[i]==0){
					some=true;
					//if (ancs[i].size()==0){
					// now we start
					//log("processing node:"+(i+1));
					time++;
					st=0;
					stack[st++]=i;
					onstack[i]=time;
					cur[i]=0;
					while (st>0){
						int u=stack[st-1];
						if (cur[u]<friends[u].size()){
							int v=friends[u].get(cur[u]);
							cur[u]++;

							if (onstack[v]<time){
								if (!processed[v]){
									processed[v]=true;
									onstack[v]=time;
									stack[st++]=v;
									cur[v]=0;
									//Arrays.fill(best[v],0);
								}

							} else {
								skip=true;
								break loop;
							}

						} else {
							onstack[u]=0;
							st--;

							for (int v:friends[u])
								for (int c=0;c<CX;c++)
									best[u][c]=Math.max(best[v][c],best[u][c]);
							int d=s.charAt(u)-'a';
							best[u][d]++;
						}
					}

				}
			}
			if (!some)
				skip=true;
			if (!skip){
				for (int c=0;c<CX;c++){
					for (int u=0;u<n;u++){
						ans=Math.max(ans,best[u][c]);
					}
				}
			}

			/*
			for (int i=0;i<n;i++){
				logWln(""+i+" ");
				log(best[i]);
			}
			 */

		}

		output(ans);


		try {
			out.close();
		}
		catch (Exception EX){}


	}


	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}


		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res=new StringBuilder();
			do {
				res.append((char)c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}




		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}


}