#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 5;
const int mod = 1e9 + 7;
const long long inf = 1e18;
int n, ans, pos, pos1;
int un[N], un1[N], cl[N], cl1[N], tr;
string t, s;
int calc(string e) {
  un[0] = cl[0] = 0, tr = 0;
  for (int i = 0; i < n; i++) {
    if (i) un[i] = un[i - 1], cl[i] = cl[i - 1];
    if (e[i] == '(')
      un[i]++;
    else {
      if (un[i])
        un[i]--;
      else
        cl[i]++;
    }
  }
  if (cl[n - 1] == 0 and un[n - 1] == 0) tr = 1;
  un1[0] = cl1[0] = 0;
  for (int i = n - 1; i >= 0; i--) {
    un1[i] = un1[i + 1], cl1[i] = cl1[i + 1];
    if (e[i] == ')')
      un1[i]++;
    else {
      if (un1[i])
        un1[i]--;
      else
        cl1[i]++;
    }
  }
  int jog = 0;
  for (int i = n - 1; i >= 1; i--)
    if (un[i - 1] == 0 and un1[i] == 0 and cl[i - 1] == cl1[i]) jog++;
  return jog + tr;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> s;
  ans = calc(s);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      t = s;
      swap(t[i], t[j]);
      if (ans < calc(t)) {
        ans = calc(t);
        pos = i, pos1 = j;
      }
    }
  }
  cout << ans << '\n' << pos + 1 << ' ' << pos1 + 1;
}
