Today is Matvey's birthday. He never knows what to ask as a present so friends gave him a string s of length n. This string consists of only first eight English letters: 'a', 'b', ..., 'h'.

First question that comes to mind is: who might ever need some string? Matvey is a special boy so he instantly found what to do with this string. He used it to build an undirected graph where vertices correspond to position in the string and there is an edge between distinct positions a and b (1 ≤ a, b ≤ n) if at least one of the following conditions hold: 

  1. a and b are neighbouring, i.e. |a - b| = 1. 
  2. Positions a and b contain equal characters, i.e. sa = sb. 



Then Matvey decided to find the diameter of this graph. Diameter is a maximum distance (length of the shortest path) among all pairs of vertices. Also, Matvey wants to find the number of pairs of vertices such that the distance between them is equal to the diameter of the graph. As he is very cool and experienced programmer he managed to solve this problem very fast. Will you do the same?

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the length of the string.

The second line contains the string s itself. It's guaranteed that s consists of only first eight letters of English alphabet.

Output

Print two integers — the diameter of the graph and the number of pairs of positions with the distance equal to the diameter.

Examples

Input

3
abc


Output

2 1


Input

7
aaabaaa


Output

2 4

Note

Consider the second sample. 

The maximum distance is 2. It's obtained for pairs (1, 4), (2, 4), (4, 6) and (4, 7).
#include <bits/stdc++.h>
using namespace std;
const int maxn = 112345;
const int inf = 0x3f3f3f3f;
int n, a[maxn], dist[maxn][8], d[8][8], c[8][1 << 8], mask[maxn];
char s[maxn];
inline void bfs(int col) {
  queue<int> que;
  dist[n + col + 1][col] = 0;
  que.push(n + col + 1);
  for (int i = 1; i <= n; ++i)
    if (col == a[i]) {
      dist[i][col] = 0;
      que.push(i);
    }
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    if (u <= n) {
      if (u > 1 && dist[u - 1][col] == inf) {
        dist[u - 1][col] = dist[u][col] + 1;
        que.push(u - 1);
        if (dist[n + a[u - 1] + 1][col] == inf) {
          dist[n + a[u - 1] + 1][col] = dist[u][col] + 1;
          que.push(n + a[u - 1] + 1);
        }
      }
      if (u < n && dist[u + 1][col] == inf) {
        dist[u + 1][col] = dist[u][col] + 1;
        que.push(u + 1);
        if (dist[n + a[u + 1] + 1][col] == inf) {
          dist[n + a[u + 1] + 1][col] = dist[u][col] + 1;
          que.push(n + a[u + 1] + 1);
        }
      }
    } else {
      for (int i = 1; i <= n; ++i)
        if (a[i] == u - n - 1 && dist[i][col] == inf) {
          dist[i][col] = dist[u][col] + 1;
          que.push(i);
        }
    }
  }
}
int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = 1; i <= n; ++i) a[i] = s[i] - 'a';
  memset(dist, 0x3f, sizeof dist);
  for (int i = 0; i < 8; ++i) {
    bfs(i);
    for (int j = 0; j < 8; ++j) d[j][i] = dist[n + j + 1][i];
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < 8; ++j)
      if (d[a[i]][j] != dist[i][j]) mask[i] |= 1 << j;
  int mx = 0;
  long long res = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = max(1, i - 15); j <= i; ++j) {
      int tmp = i - j;
      for (int k = 0; k < 8; ++k) tmp = min(tmp, dist[i][k] + dist[j][k] + 1);
      if (tmp > mx)
        mx = tmp, res = 1;
      else if (tmp == mx)
        ++res;
    }
    int j = i - 16;
    if (j >= 1) ++c[a[j]][mask[j]];
    for (int j = 0; j < 8; ++j)
      for (int k = 0; k < 256; ++k)
        if (c[j][k]) {
          int tmp = inf;
          for (int l = 0; l < 8; ++l)
            tmp = min(tmp, dist[i][l] + d[j][l] + (k >> l & 1) + 1);
          if (tmp > mx)
            mx = tmp, res = c[j][k];
          else if (tmp == mx)
            res += c[j][k];
        }
  }
  return 0 * printf("%d %I64d\n", mx, res);
}
