#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
const int M = 2e6 + 100;
const int _ = 1e5 + 7;
int hd[N], pre[M], to[M], num;
int dis[N], tot, n;
void adde(int x, int y) {
  num++;
  pre[num] = hd[x];
  hd[x] = num;
  to[num] = y;
}
queue<int> q;
vector<int> g[N];
bitset<_> f[300];
int fcnt[300];
int len = -1;
long long ans;
void update(int l, long long x) {
  if (l > len)
    len = l, ans = x;
  else if (l == len)
    ans += x;
}
void dfs(int v, int s) {
  if (v > n && v <= n + 8) {
    f[(1 << (v - n - 1))][s] = 1;
    return;
  }
  if (dis[v] == 1) {
    if (!g[v].size() || *--g[v].end() != s) g[v].push_back(s);
    return;
  }
  for (int i = hd[v]; i; i = pre[i]) {
    int u = to[i];
    if (dis[u] == dis[v] - 1) dfs(u, s);
  }
}
int cov[N], d[N];
void bfs(int c) {
  for (int i = 1; i <= tot; i++) dis[i] = -1;
  dis[n + c] = 0, q.push(n + c);
  int maxd = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (dis[v] & 1) maxd = max(maxd, dis[v]);
    for (int i = hd[v]; i; i = pre[i]) {
      int u = to[i];
      if (dis[u] == -1) dis[u] = dis[v] + 1, q.push(u);
    }
  }
  for (int i = 1; i <= 8; i++)
    if (i != c) f[1 << (i - 1)].reset();
  int m = 0, k = 0;
  for (int i = 1; i <= tot; i++)
    if (dis[i] == maxd) dfs(i, i), m++;
  for (int i = 1; i < (1 << 8); i++)
    if (!(i >> (c - 1) & 1)) {
      if (i != (i & -i)) {
        f[i] = f[i - (i & -i)] | f[i & -i];
      }
      fcnt[i] = f[i].count();
    }
  for (int i = 1; i <= tot; i++) cov[i] = 0;
  for (int i = 1; i <= 8; i++)
    if (i != c) cov[n + i] = (1 << (i - 1));
  for (int v = 1; v <= tot; v++)
    if (dis[v] > 1)
      for (int i = hd[v]; i; i = pre[i]) {
        int u = to[i];
        if (dis[u] == dis[v] - 1) d[u]++;
      }
  for (int i = 1; i <= tot; i++)
    if (!d[i]) q.push(i);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (dis[v] == 1) continue;
    for (int i = hd[v]; i; i = pre[i]) {
      int u = to[i];
      if (dis[u] == dis[v] - 1) {
        cov[u] |= cov[v];
        d[u]--;
        if (!d[u]) q.push(u);
      }
    }
  }
  int len = maxd - 1;
  long long ans = 0;
  for (int v = 1; v <= tot; v++)
    if (dis[v] == 1) {
      k++;
      int cnt = fcnt[cov[v]];
      for (int i = 0, s = g[v].size(); i < s; i++)
        if (!f[cov[v]][g[v][i]]) cnt++;
      if (cnt < m) len = maxd + 1, ans += m - cnt;
    }
  if (len == maxd - 1) {
    ans = 1ll * k * m;
    for (int i = 1; i <= 8; i++)
      if (i != c) f[1 << (i - 1)].reset();
    m = 0, k = 0;
    for (int i = 1; i <= tot; i++)
      if (dis[i] == 1) g[i].clear();
    for (int i = 1; i <= tot; i++)
      if (dis[i] == maxd - 2) dfs(i, i), m++;
    for (int i = 1; i < (1 << 8); i++)
      if (!(i >> (c - 1) & 1)) {
        if (i != (i & -i)) {
          f[i] = f[i - (i & -i)] | f[i & -i];
        }
        fcnt[i] = f[i].count();
      }
    for (int i = 1; i <= tot; i++) cov[i] = 0;
    for (int i = 1; i <= 8; i++)
      if (i != c) cov[n + i] = (1 << (i - 1));
    for (int v = 1; v <= tot; v++)
      if (dis[v] > 1)
        for (int i = hd[v]; i; i = pre[i]) {
          int u = to[i];
          if (dis[u] == dis[v] - 1) d[u]++;
        }
    for (int i = 1; i <= tot; i++)
      if (!d[i]) q.push(i);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      if (dis[v] == 1) continue;
      for (int i = hd[v]; i; i = pre[i]) {
        int u = to[i];
        if (dis[u] == dis[v] - 1) {
          cov[u] |= cov[v];
          d[u]--;
          if (!d[u]) q.push(u);
        }
      }
    }
    for (int v = 1; v <= tot; v++)
      if (dis[v] == 1) {
        k++;
        int cnt = fcnt[cov[v]];
        for (int i = 0, s = g[v].size(); i < s; i++)
          if (!f[cov[v]][g[v][i]]) cnt++;
        ans += m - cnt;
      }
    update(len, ans);
  } else
    update(maxd + 1, ans);
}
int cl[N];
bool use[10];
char fafs[100010];
int main() {
  scanf("%d", &n);
  scanf("%s", fafs + 1);
  if (n == 1) printf("%d %d\n", 0, 1), exit(0);
  tot = n + 8;
  for (int i = 1; i <= n; i++) {
    cl[i] = fafs[i] - 'a';
    cl[i]++;
    use[cl[i]] = 1;
    adde(i, n + cl[i]), adde(n + cl[i], i);
  }
  for (int i = 1; i < n; i++) {
    ++tot;
    adde(i, tot), adde(tot, i);
    adde(i + 1, tot), adde(tot, i + 1);
  }
  for (int i = 1; i <= 8; i++)
    if (use[i]) bfs(i);
  printf("%d %lld\n", len / 2, ans / 2);
  return 0;
}
