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;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int lcm(long long int a, long long int b) {
  return (a / gcd(a, b)) * b;
}
long long int searchll(long long int val, vector<long long int> vec) {
  for (long long int i = 0; i < vec.size(); i++) {
    if (vec[i] == val) {
      return i;
    }
  }
  return -1;
}
bool isPrime(long long int n) {
  int broken = 0;
  for (long long int i = 2; i < sqrt(n) + 1; i++) {
    if (n % i == 0) {
      broken = 1;
      break;
    }
  }
  if (broken == 1) {
    return false;
  } else {
    return true;
  }
}
bool isPerfectSquare(long double x) {
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
}
vector<bool> SieveOfEratosthenes(long long int num) {
  vector<bool> pno;
  pno.assign(num + 1, true);
  pno[0] = false;
  pno[1] = false;
  for (long long int i = 2; i * i <= num; i++) {
    if (pno[i] == true) {
      for (long long int j = i * 2; j <= num; j += i) pno[j] = false;
    }
  }
  return pno;
}
vector<long long int> SieveOfEratosthenesExtended(long long int num) {
  vector<long long int> pno(num + 1);
  for (long long int i = 0; i < num + 1; i++) {
    pno[i] = i;
  }
  for (long long int i = 2; i * i <= num; i++) {
    if (pno[i] == i) {
      for (long long int j = i * 2; j <= num; j += i)
        if (pno[j] == j) pno[j] = i;
    }
  }
  return pno;
}
vector<long long int> PrimeFactorize(long long int num) {
  vector<long long int> spf;
  spf = SieveOfEratosthenesExtended(num);
  set<long long int> pf;
  while (num != 1) {
    pf.insert(spf[num]);
    num = num / spf[num];
  }
  vector<long long int> v;
  for (auto it : pf) {
    v.push_back(it);
  }
  return v;
}
long long int calculateNcR(long long int n, long long int r) {
  long long int p = 1, k = 1;
  if (n - r < r) r = n - r;
  if (r != 0) {
    while (r) {
      p *= n;
      k *= r;
      long long int m = gcd(p, k);
      p /= m;
      k /= m;
      n--;
      r--;
    }
  } else
    p = 1;
  return p;
}
long long int stringToInt(string s) {
  long long int num = 0;
  for (long long int i = 0; i < s.length(); i++) {
    num = num * 10 + (s[i] - '0');
  }
  return num;
}
long long int BinarySearch(vector<long long int> arr, long long int num) {
  long long int left = 0, right = arr.size(), mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (arr[mid] == num) {
      return mid;
    } else if (arr[mid] < num) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }
  return left;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, m;
  cin >> n;
  cin >> m;
  string s;
  cin >> s;
  long long int f[n][26];
  long long int deg[n];
  vector<vector<long long int>> adj(n, vector<long long int>());
  for (long long int i = 0; i < n; i++) {
    deg[i] = 0;
    for (long long int j = 0; j < 26; j++) {
      f[i][j] = 0;
    }
  }
  long long int u, v;
  for (long long int i = 0; i < m; i++) {
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    deg[v]++;
  }
  long long int cnt = 0;
  deque<long long int> que;
  for (long long int i = 0; i < n; i++) {
    if (deg[i] == 0) {
      que.push_back(i);
      f[i][s[i] - 'a'] = 1;
    }
  }
  long long int node;
  while (!que.empty()) {
    node = que.front();
    que.pop_front();
    for (long long int neigh : adj[node]) {
      int ind = s[neigh] - 'a';
      for (long long int i = 0; i < 26; i++) {
        if (ind == i) {
          f[neigh][i] = max(f[neigh][i], f[node][i] + 1);
        } else {
          f[neigh][i] = max(f[neigh][i], f[node][i]);
        }
      }
      deg[neigh]--;
      if (deg[neigh] == 0) {
        que.push_back(neigh);
      }
    }
    cnt++;
  }
  if (cnt == n) {
    long long int max_val = 0;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < 26; j++) {
        if (f[i][j] > max_val) {
          max_val = f[i][j];
        }
      }
    }
    cout << max_val << "\n";
  } else {
    cout << -1 << "\n";
  }
}
