#include <bits/stdc++.h>
using namespace std;
int n;
char str[1010];
int a[1010], sum[1010], min1[1010], min2[1010];
int calc(int l, int r) {
  swap(a[l], a[r]);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  if (sum[n] != 0) return -1;
  memset(min1, 0, sizeof(min1));
  memset(min2, 0, sizeof(min2));
  min1[1] = sum[1];
  for (int i = 2; i <= n; i++) min1[i] = min(min1[i - 1], sum[i]);
  min2[n] = sum[n];
  for (int i = n - 1; i >= 1; i--) min2[i] = min(min2[i + 1], sum[i]);
  int ret = 0;
  for (int i = 1; i <= n; i++)
    if (min2[i] - sum[i - 1] >= 0 && min1[i - 1] - sum[i - 1] >= 0) ret++;
  swap(a[l], a[r]);
  return ret;
}
int main() {
  cin >> n;
  scanf("%s", str);
  for (int i = 1; i <= n; i++)
    if (str[i - 1] == '(')
      a[i] = 1;
    else
      a[i] = -1;
  int ans = 0, maxl = 1, maxr = 1;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) {
      int tmp = calc(i, j);
      if (ans < tmp) {
        ans = tmp;
        maxl = i;
        maxr = j;
      }
    }
  printf("%d\n%d %d\n", ans, maxl, maxr);
  return 0;
}
