OJ-Problems-Source/HDOJ/1870.cpp

22 lines
377 B
C++
Raw Permalink Normal View History

2016-08-31 15:31:55 +08:00
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
char buffer[1024];
int main()
{
while(scanf("%s",buffer)==1)
{
int idt=strstr(buffer,"B")-buffer;
int cnt=0;
for(int i=idt-1;i>=0;i--)
{
if(buffer[i]=='(') cnt++;
else cnt--;
}
printf("%d\n",cnt);
}
return 0;
}