import java.util.Scanner; public class Beth { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); scanner.nextInt(); scanner.nextLine(); String row = scanner.nextLine(); int result = 0; for (int i = 0; i < row.length() - 1; i++) { char current = row.charAt(i); char next = row.charAt(i + 1); if (current == '(' && next == ')') { result++; } else if (current == ')' && next == ')') { result++; } } System.out.println(result); } }