#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[100015];
int a[100015];
vector<int> u[100015];
int dst[100015][15];
bool proc[100015];
void clc(int l) {
  for (int i = (0); i < (n + m); i++) {
    dst[i][l] = 1e9;
    proc[i] = false;
  }
  deque<int> q;
  q.push_back(n + l);
  dst[n + l][l] = 0;
  while (!q.empty()) {
    int i = q.front();
    q.pop_front();
    if (proc[i]) continue;
    proc[i] = true;
    for (int j : u[i]) {
      int nd = dst[i][l];
      if (i < n) {
        nd++;
      }
      if (nd < dst[j][l]) {
        dst[j][l] = nd;
        if (i < n)
          q.push_back(j);
        else
          q.push_front(j);
      }
    }
  }
}
int c[8][2 << 21];
void add(vector<int> v) {
  for (int i = (0); i < (m); i++)
    if (v[i] == 0) {
      int r = 0;
      int ind = 0;
      for (int j = (0); j < (m); j++)
        if (j != i) {
          assert(1 <= v[j] && v[j] <= 8);
          r |= (8 - v[j]) << ind;
          ind += 3;
        }
      c[i][r]++;
      return;
    }
  assert(false);
}
vector<int> mv[100005];
long long qu(int i, int d) {
  vector<int> ov(m);
  for (int j = (0); j < (m); j++) {
    for (int k = (0); k < (m); k++) {
      if (mv[i][j] != 8) {
        ov[k] = max(ov[k], d - (mv[i][j] + dst[j + n][k] + 1));
        ov[k] = min(ov[k], 8);
      }
    }
  }
  long long res = 0;
  for (int j = (0); j < (m); j++)
    if (ov[j] == 0) {
      int r = 0;
      int ind = 0;
      for (int k = (0); k < (m); k++)
        if (k != j) {
          int l = ov[k];
          if (l == 0) l = 1;
          r |= (8 - l) << ind;
          ind += 3;
        }
      res += c[j][r];
    }
  for (int j = i - d + 1; j <= i + d - 1; j++)
    if (0 <= j && j < n) {
      bool allgrt = true;
      for (int k = (0); k < (m); k++) allgrt &= mv[j][k] >= ov[k];
      if (allgrt) res--;
    }
  return res;
}
long long cntg(int d) {
  long long res = 0;
  for (int i = (0); i < (n); i++) res += qu(i, d);
  assert(res % 2 == 0);
  return res / 2;
}
int main() {
  scanf("%d %s", &n, s);
  map<char, int> seen;
  for (int i = (0); i < (n); i++) {
    if (!seen.count(s[i])) {
      int j = int(seen.size());
      seen[s[i]] = j;
    }
    a[i] = seen[s[i]];
  }
  m = int(seen.size());
  for (int i = (0); i < (n); i++) {
    if (i) u[i].push_back(i - 1);
    if (i + 1 < n) u[i].push_back(i + 1);
    u[n + a[i]].push_back(i);
    u[i].push_back(n + a[i]);
  }
  for (int i = (0); i < (m); i++) clc(i);
  for (int i = (0); i < (n); i++) {
    vector<int> v;
    for (int j = (0); j < (m); j++) {
      int ldst = dst[i][j];
      if (ldst >= 8) ldst = 8;
      v.push_back(ldst);
    }
    add(v);
    mv[i] = v;
  }
  for (int i = (0); i < (m); i++) {
    for (int j = (0); j < (m - 1); j++) {
      for (int t = (0); t < (1 << (3 * (m - 1))); t++) {
        if (t & (7 << (j * 3))) {
          c[i][t] += c[i][t - (1 << (j * 3))];
        }
      }
    }
  }
  long long lst = 0;
  for (int i = (1); i < (100); i++) {
    long long nk = cntg(i);
    if (nk == 0) {
      printf("%d %lld\n", i - 1, lst);
      return 0;
    }
    lst = nk;
  }
}
