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.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Almaz
 */
public class D {

    public static int ans = 0;
    public static int cur = 0;    
    public static boolean cyclic = false;    
    public static int a[][] = new int[300001][26];    
    	static class Node
	{
		int data;
		boolean visited;
		List<Node> neighbours;
                int x;
                int color = 0;
 
		Node(int data, int x)
		{
			this.data=data;
                        this.x = x;
			this.neighbours = new ArrayList<>();
 
		}
		public void addneighbours(Node neighbourNode)
		{
			this.neighbours.add(neighbourNode);
		}
		public List<Node> getNeighbours() {
			return neighbours;
		}
		public void setNeighbours(List<Node> neighbours) {
			this.neighbours = neighbours;
		}
	}
        
    public static void dfs(Node node)
	{
//		System.out.print(node.data + " ");
		List neighbours = node.getNeighbours();
                node.visited=true;
		for (int i = 0; i < neighbours.size(); i++) {
			Node n = (Node) neighbours.get(i);
			if(n != null && !n.visited)
			{
                            dfs(n);
			}
                        for (int j = 0;j < 26; j++)
                            a[node.x][j] = Math.max(a[node.x][j], (j == n.data ? 1 : 0) + a[n.x][j]);
		}
//                a[node.x][node.data] = a[node.x][node.data] + 1;
//                a[node.data]--;
	}
    
        public static boolean findCycle(Node node)
	{
//                System.out.println("GO = " + node.x);
		List<Node> neighbours = node.getNeighbours();
                node.color = 1;
		for (int i = 0; i < neighbours.size(); i++) {
			Node n = (Node) neighbours.get(i);
//                        if (n != null) {
//                            System.out.println(n.x + " " + n.color);
//                        }
			if(n != null && n.color == 0)
			{
                            if (findCycle(n)) return true;
			} else 
                        if (n != null && n.color == 1){
                            cyclic = true;
                            return true;
                        }
		}
                node.color = 2;
                return false;
	}
    
    public static void main(String[] args) throws IOException {
//        Scanner in = new Scanner(System.in);
//        BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String ar[] = in.readLine().split(" ");
        int n = Integer.parseInt(ar[0]);
        int m = Integer.parseInt(ar[1]);        
        String s = in.readLine();
        Node nodes[] = new Node[n + 1];
        for (int i = 0; i < n; i++) {
            nodes[i + 1] = new Node(s.charAt(i) - 97, (i + 1));
        }
        for (int i = 0; i < m; i++) {
            ar = in.readLine().split(" ");
            int x = Integer.parseInt(ar[0]);
            int y = Integer.parseInt(ar[1]);            
            nodes[x].addneighbours(nodes[y]);
        }
        for (int i = 1; i <= n; i++)
            if (nodes[i].color == 0 && findCycle(nodes[i])) {
               break;
            }
        if (cyclic) {
            System.out.println(-1);
            return;
        }
        
        for (int i = 1; i <= n; i++) {
            if (!nodes[i].visited) {
                dfs(nodes[i]);
            }
            for (int j = 0; j < 26; j++)
                ans = Math.max(ans, a[i][j] + (j == nodes[i].data ? 1 : 0));
        }
        //System.out.println();
        System.out.println(ans);

    }
}
