#include #include int main() { int rozmer, result=0; scanf("%d", &rozmer); char *m = (char*)malloc( sizeof(char)*rozmer ); scanf("%c", &m[0]); for ( int i = 0; i < rozmer; i++ ) { scanf("%c", &m[i]); } for (int i = 0; i < rozmer-1; i++) { if ( m[i] == ')' ) { if ( m[i+1] == ')' ) { result++; } } if ( m[i] == '(' ) { if ( m[i+1] == ')' ) { result++; } } } free(m); printf("%d", result); return 0; }