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.util.*;
import java.io.*;
import java.math.*;
public class Main {

    void solve() {
        int n=ni(),m=ni();
        s=ns().toCharArray();
        int[] from = new int[m];
        int[] to = new int[m];


        vis=new boolean[26][n];
        vis2=new boolean[n+1];

        for(int i=0;i<m;i++){
            int x=ni()-1,y=ni()-1;
            if(x==y) ans=false;

           from[i]=x;
           to[i]=y;
        }
        g = packD(n, from, to);
        if(ans)
            for(int i=0;i<n;i++) {
                if(!vis[0][i]) dfs(i);
            }
        if(!ans){
            pw.println("-1");
            return;
        }

        ArrayList<Integer> l1=new ArrayList<>();
        while(!stk.isEmpty()) l1.add(stk.pop());
        int mx=0;
        cnt=new int[26][n];
        Arrays.fill(vis[0],false);
        for(int ch=0;ch<26;ch++){


            for(int v : l1) {


                if(!vis[ch][v]){
                    mx=Math.max(mx,dfs2(v,-1,ch));
                }
            }

        }

        pw.println(mx);


    }
    static int[][] packD(int n, int[] from, int[] to) {
        int[][] g = new int[n][];
        int[] p = new int[n];
        for (int f : from)
            p[f]++;
        for (int i = 0; i < n; i++)
            g[i] = new int[p[i]];
        for (int i = 0; i < from.length; i++) {
            g[from[i]][--p[from[i]]] = to[i];
        }
        return g;
    }
    int g[][];
    int cnt[][];
    char s[];

    Stack<Integer> stk=new Stack<>();
    boolean vis[][];
    boolean vis2[];
    boolean ans=true;

    void dfs(int v){
        vis[0][v]=true;
        vis2[v]=true;
       // pw.println(v);

        for(int u : g[v]){
            if(!vis[0][u]) dfs(u);
            else {
                if (vis2[u]){
                    ans = false;
                   // pw.println(u+" "+v);
                }

            }
        }
        vis2[v]=false;
        stk.push(v);
    }
    int dfs2(int v,int pr,int ch){
        // pw.println(v+" "+ch);
        vis[ch][v]=true;
        int cc=0;
        int d=0;

        if(s[v]-'a'==ch) d=1;
        for(int u : g[v]){
            if(!vis[ch][u]){
                cc=Math.max(cc,dfs2(u,v,ch));
            }else if(u!=pr) {
                cc=Math.max(cc,cnt[ch][u]);
            }
        }

        cnt[ch][v]=cc+d;
        // if(v==4 ) pw.println((cc)+" "+d);
        return cc+d;
    }

    long M=(long)1e9+7;
    InputStream is;
    PrintWriter pw;
    String INPUT = "";
    void run() throws Exception {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
        if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
    }

    public static void main(String[] args) throws Exception { new Main().run(); }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if(lenbuf == -1)throw new InputMismatchException();
        if(ptrbuf >= lenbuf){
            ptrbuf = 0;
            try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
            if(lenbuf <= 0)return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
    private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

    private double nd() { return Double.parseDouble(ns()); }
    private char nc() { return (char)skip(); }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while(p < n && !(isSpaceChar(b))){
            buf[p++] = (char)b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for(int i = 0;i < n;i++)map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for(int i = 0;i < n;i++)a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private void tr(Object... o) { if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o)); }
}