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.
#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T a, T b = 0) {
  if (b == 0) return (a < 0) ? -a : a;
  return (a > b) ? (a - b) : (b - a);
}
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
long long xp(long long b, long long n, long long m) {
  long long r = 1;
  while (n > 0) {
    if (n & 1) {
      r = r * b;
      if (r >= m) r %= m;
    }
    n >>= 1;
    b = b * b;
    if (b >= m) b %= m;
  }
  return r % m;
}
long long inv(long long a, long long m) { return xp(a, m - 2, m); }
bool pali(string temp, int i, int j) {
  if (i >= j) return true;
  if (temp[i] == temp[j]) return pali(temp, i + 1, j - 1);
  return false;
}
template <typename F, typename S>
ostream &operator<<(ostream &os, const pair<F, S> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  typename vector<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ",";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  typename set<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ",";
    os << *it;
  }
  return os << "]";
}
template <typename F, typename S>
ostream &operator<<(ostream &os, const map<F, S> &v) {
  os << "[";
  typename map<F, S>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ",";
    os << it->first << "=" << it->second;
  }
  return os << "]";
}
int vis[300002];
char value[300002];
vector<int> node[300002];
int letter;
int n;
enum Color { WHITE, GRAY, BLACK };
bool DFSUtil(int u, int color[]) {
  color[u] = GRAY;
  vector<int>::iterator i;
  for (i = node[u].begin(); i != node[u].end(); ++i) {
    int v = *i;
    if (color[v] == GRAY) return true;
    if (color[v] == WHITE && DFSUtil(v, color)) return true;
  }
  color[u] = BLACK;
  return false;
}
bool cycle() {
  int *color = new int[n];
  for (int i = 0; i < n; i++) color[i] = WHITE;
  for (int i = 0; i < n; i++)
    if (color[i] == WHITE)
      if (DFSUtil(i, color) == true) return true;
  return false;
}
int val(int i) { return value[i] - 'a'; }
int dp[300002][30];
int call(int u, int letter) {
  if (dp[u][letter] != -1) return dp[u][letter];
  int ret = 0;
  int sz = node[u].size();
  for (int i = 0; i < sz; i++) ret = max(ret, call(node[u][i], letter));
  if (val(u) == letter) ret++;
  return dp[u][letter] = ret;
}
int main() {
  cin >> n;
  int m;
  scanf("%d", &m);
  ;
  memset(vis, -1, sizeof(vis));
  for (int i = 1; i < n + 1; i++) {
    char ch;
    cin >> ch;
    value[i] = ch;
  }
  for (int i = 0; i < m; i++) {
    int a;
    scanf("%d", &a);
    ;
    int b;
    scanf("%d", &b);
    ;
    node[a].push_back(b);
    if (a == b) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (cycle()) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i < n + 1; i++)
    for (int j = 0; j < 26; j++) ans = max(ans, call(i, j));
  cout << ans << endl;
  return 0;
}
