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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedInputStream;
import java.util.Iterator;
import java.io.FilterInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author khokharnikunj8
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        String s;
        LinkedListCustom<Integer>[] ln;
        boolean[] visited;
        boolean[] universal;
        boolean flag;
        int[][] temp;
        long ans;

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int m = in.scanInt();
            s = in.scanString();
            visited = new boolean[n + 1];
            universal = new boolean[n + 1];
            ln = new LinkedListCustom[n + 1];
            for (int i = 1; i <= n; i++) ln[i] = new LinkedListCustom<>();
            flag = false;
            temp = new int[n + 1][26];
            ans = Long.MIN_VALUE;
            for (int i = 0; i < m; i++) ln[in.scanInt()].add(in.scanInt());
            for (int i = 1; i <= n; i++) dfs(i);
            if (flag) out.println(-1);
            else out.println(ans);
        }

        private void dfs(int node) {
            if (universal[node]) return;
            if (visited[node]) return;
            visited[node] = true;
            universal[node] = true;
            Iterator<Integer> it = ln[node].iterator();
            while (it.hasNext()) {
                int temp1 = it.next();
                if (!visited[temp1]) {
                    if (!universal[temp1]) dfs(temp1);
                    for (int i = 0; i < 26; i++) temp[node][i] = Math.max(temp[temp1][i], temp[node][i]);
                } else {
                    flag = true;
                    return;
                }
            }
            temp[node][(int) s.charAt(node - 1) - 97]++;
            for (int i = 0; i < 26; i++) ans = Math.max(ans, temp[node][i]);
            visited[node] = false;
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        public String scanString() {
            int c = scan();
            if (c == -1) return null;
            while (isWhiteSpace(c)) c = scan();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = scan();
            } while (!isWhiteSpace(c));
            return res.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }

    static class LinkedListCustom<T extends Comparable<? super T>> {
        private Node<T> __tempnode;
        private Node<T> __first;
        private Node<T> __last;
        private Node<T> __mid;
        private int __size;

        public LinkedListCustom() {
            __first = null;
            __last = null;
            __mid = null;
            __size = 0;
        }

        public void add(T data) {
            __tempnode = new Node<>(data);
            if (__size == 0) {
                __first = __last = __mid = __tempnode;
            } else {
                __tempnode.previous = __last;
                __last.next = __tempnode;
                __last = __tempnode;
                if ((__size & 1) == 0) __mid = __mid.next;
            }
            __size++;
        }

        public Iterator<T> iterator() {
            Iterator<T> it = new Iterator<T>() {
                private int currentIndex = 0;
                private Node<T> iterate = __first;

                public boolean hasNext() {
                    return currentIndex < __size;
                }


                public T next() {
                    currentIndex++;
                    __tempnode = iterate;
                    iterate = iterate.next;
                    return __tempnode.data;
                }


                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
            return it;
        }

        private class Node<T> {
            Node<T> previous;
            Node<T> next;
            T data;

            public Node(T data) {
                this.data = data;
                previous = null;
                next = null;
            }

        }

    }
}

