/*
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
#include <stdio.h>
#include <string.h>
#define SIZE 201
int top;
int st[SIZE];
void init()
{
top = 0;
}
void push(int c) // c 12421421
{
if(top == SIZE)
{
return;
}
top++;
st[top] = c;
}
void pop()
{
if(top == 0)
{
return;
}
printf("%d",st[top]);
st[top] = 0;
top--;
}
int main()
{
int n;
char str[SIZE];
scanf("%d",&n);
scanf("%s",str);
init();
for(int i = n-1 ; i>=0; i--)
{
push(str[i]-48);
}
for(int p = n; p >=1 ; p--)
{
if((p % 3 == 0)&&(top != n))
{
printf(",");
}
pop();
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
#define SIZE 500000
int top;
char st[SIZE];
void init()
{
top = -1;
}
void push(char q)
{
if(top == SIZE-1)
{
return;
}
top++;
st[top] = q;
}
void pop()
{
if(top == -1)
{
return;
}
st[top] = ' ';
top--;
}
void view()
{
printf("\n====================\n");
for(int i = 0; i<=top; i++)
{
printf("%c ",st[i]);
}
printf("\n====================\n");
}
int main()
{
char a, k[SIZE];
scanf("%s",k);
init();
for(int i = 0; i < strlen(k); i++)
{
if(k[i] == '(')
{
push(k[i]);
}
else
{
if(st[top] == '(')
{
pop();
}
else
{
printf("bad");
return 0;
}
}
}
if(top == -1)
{
printf("good");
}
else
{
printf("bad");
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
#define SIZE 100000
int top;
char st[SIZE];
void init()
{
top = -1;
}
void push(char z)
{
if(top == SIZE-1)
{
return;
}
top++;
st[top] = z;
}
void pop()
{
if(top == -1)
{
return;
}
st[top] = ' ';
top--;
}
int main()
{
char k[SIZE];
int fe =0;
init();
scanf("%s",k);
for(int i = 0; i < strlen(k); i++)
{
if(k[i] == '(')
{
push(k[i]);
}
else
{
if(k[i-1] == '(')
{
pop();
fe += top + 1;
}
else
{
pop();
fe++;
}
}
}
printf("%d",fe);
return 0;
}
*/