#include <bits/stdc++.h>
using namespace std;
const long long N = (1 << 20) + 7, mod = 1e9 + 7;
string s;
int n, sum[1200];
int get(int x, int y) {
  string t = s + s;
  swap(t[x - 1], t[y - 1]);
  swap(t[x - 1 + n], t[y - 1 + n]);
  if (t[0] == ')')
    sum[0] = -1;
  else
    sum[0] = 1;
  for (int i = 1; i < 2 * n; i++) {
    if (t[i] == ')')
      sum[i] = sum[i - 1] - 1;
    else
      sum[i] = sum[i - 1] + 1;
  }
  queue<int> q;
  int c = 0;
  for (int i = 0; i < n; i++) {
    while (q.size() && sum[q.front()] >= sum[i]) q.pop();
    q.push(i);
  }
  for (int i = n; i < 2 * n; i++) {
    if (q.front() == i - n) q.pop();
    while (q.size() && sum[q.front()] >= sum[i]) q.pop();
    q.push(i);
    if (sum[q.front()] >= sum[i - n] && sum[i - n] == sum[i]) c++;
  }
  return c;
}
int main() {
  scanf("%d", &n);
  cin >> s;
  int ma = get(1, 1), l = 1, r = 1;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      int k = get(i, j);
      if (k > ma) {
        ma = k;
        l = i;
        r = j;
      }
    }
  printf("%d\n", ma);
  printf("%d %d\n", l, r);
}
