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.
//package math_codet;

import java.io.*;
import java.util.*;
import java.math.*;
 /******************************************
*    AUTHOR:         AMAN KUMAR SINGH        *
*    INSTITUITION:   KALYANI GOVERNMENT ENGINEERING COLLEGE  *
******************************************/
public class lets_do {
    InputReader in;
    PrintWriter out;
    Helper_class h;
    final long mod=1000000007;
    final int N=200005;
    int MAX_Ai=100005;
    public static void main(String[] args) throws java.lang.Exception{
        new lets_do().run();
    }
    void run() throws Exception{
        in=new InputReader(System.in);
        out = new PrintWriter(System.out);
        h = new Helper_class();
        int t=1;
        while(t-->0){
            solve();
        }
        out.flush();    
        out.close();
    }
    void topologicalSortUtil(int v, boolean visited[], Stack stack)                  
    {
        visited[v] = true;
        Integer i;
        Iterator<Integer> it = graph[v].iterator();
        while (it.hasNext())
        {
            i = it.next();
            if (!visited[i])
                topologicalSortUtil(i, visited, stack);
        }
        stack.push(new Integer(v));
    }
    ArrayList<Integer> topo_sort=new ArrayList<Integer>();
    void topologicalSort()
    {
        Stack stack = new Stack();
        boolean visited[] = new boolean[n+1];
        for (int i = 1; i <= n; i++)
            visited[i] = false;
        for (int i = 1; i <= n; i++)
            if (visited[i] == false)
                topologicalSortUtil(i, visited, stack);
        while (stack.empty()==false)
            topo_sort.add((int)stack.pop());
    }

    boolean isCyclicUtil(int i, boolean[] visited, boolean[] recStack){
        if (recStack[i])
            return true;
        if (visited[i])
            return false;
        visited[i] = true;
        recStack[i] = true;
        for (int c: graph[i])
            if (isCyclicUtil(c, visited, recStack))
                return true;
        recStack[i] = false;
        return false;
    }

    boolean isCyclic() {
        boolean[] visited = new boolean[n+1];
        boolean[] recStack = new boolean[n+1];
        for (int i = 1; i <= n; i++)
            if (isCyclicUtil(i, visited, recStack))
                return true;
        return false;
    }
    ArrayList<Integer>[] graph;
    int n;
    void solve(){
        n=h.ni();
        int m=h.ni();
        graph=new ArrayList[n+1];
        int i=0,j=0;
        for(i=1;i<=n;i++)
            graph[i]=new ArrayList<Integer>();
        String st=h.n();
        for(i=0;i<m;i++)
            graph[h.ni()].add(h.ni());
        if(isCyclic())
            h.pn(-1);
        else{
            topologicalSort();
            int[][] freq=new int[n+1][26];
            int[][] curr_val=new int[n+1][26];
            for(i=0;i<n;i++)
                freq[i+1][st.charAt(i)-'a']++;
            for(i=1;i<=n;i++)
            	curr_val[i][st.charAt(i-1)-'a']++;
            for(i=0;i<topo_sort.size();i++){
                for(int u: graph[topo_sort.get(i)]){
                    for(int k=0;k<26;k++)
                        curr_val[u][k]=Math.max(curr_val[u][k],curr_val[topo_sort.get(i)][k]+freq[u][k]);
                }
            }
            int max=0;
            for(i=1;i<=n;i++){
                for(j=0;j<26;j++)
                    max=Math.max(curr_val[i][j],max);
            }
            h.pn(max);
        }
    }
    

    final Comparator<Entity> com=new Comparator<Entity>(){
        public int compare(Entity x, Entity y){
            int xx=Integer.compare(x.a,y.a);
            if(xx==0){
                int xxx=Integer.compare(x.b,y.b);
                return xxx;
            }
            else
                return xx;
        }
    };
    class Entity{
        int a;
        int b;
        Entity(int p, int q){
            a=p;
            b=q;
        }
    }
    

    class Helper_class{
        long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
        int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
        long gcd1(long a, long b){return (b==0)?a:gcd(b,a%b);}
        int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
        void p(Object o){out.print(o);}
        void pn(Object o){out.println(o);}
        void pni(Object o){out.println(o);out.flush();}
        String n(){return in.next();}
        String nln(){return in.nextLine();}
        int ni(){return in.nextInt();}
        long nl(){return in.nextLong();}
        double nd(){return in.nextDouble();}

        long mul(long a,long b){
            if(a>=mod)a%=mod;
            if(b>=mod)b%=mod;
            a*=b;
            if(a>=mod)a%=mod;
            return a;
        }
        long modPow(long a, long p){
            long o = 1;
            while(p>0){
                if((p&1)==1)o = mul(o,a);
                a = mul(a,a);
                p>>=1;
            }
            return o;
        }
        long add(long a, long b){
            if(a>=mod)a%=mod;
            if(b>=mod)b%=mod;
            if(b<0)b+=mod;
            a+=b;
            if(a>=mod)a-=mod;
            return a;
        }
    }

    class InputReader{
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
 
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
 
        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
 
        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }
 
        public void skip(int x) {
            while (x-- > 0)
                read();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
        public long nextLong() {
            return Long.parseLong(next());
        }
 
        public String nextString() {
            return next();
        }
 
        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
 
            return res.toString();
        }
 
        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }
 
        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
 
        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }
 
        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}