import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ Main m = new Main(); m.input(); m.solve(); } int n; String s; String[] sp; public void input(){ Scanner sc = new Scanner(System.in); n = sc.nextInt(); s = sc.next(); sp = s.split(""); sc.close(); } int count; public void solve(){ for(int i = 0; i < n; i++){ if(sp[i].equals("(")){ count = 1; for(int j = i + 1; j < n; j++){ if(sp[j].equals("(")){ count++; }else{ count--; } if(count == 0){ System.out.println(j + 1); break; } } }else{ count = 1; for(int j = i - 1; j >= 0; j--){ if(sp[j].equals(")")){ count++; }else{ count--; } if(count == 0){ System.out.println(j + 1); break; } } } } } }