#include <stdio.h>
#include <string.h>
int scoreofparentheses(char*s)
{
    int stack[50], top =-1;
    stack [ ++0 ; top=0 ];
    for (int i=0;s[i]!='\0';i++)
    {
        if (s[i]=='('))
    {
        else if (s[i] ==')')
    {
       if(Top<1)return-1;
       int v = stack [top -- ];
       int w = stack [top];
       stack [Top] =w+(v ==0? 1:2*v);
                
    }else
    {
                return -1;
            }
        }
        if (top !=0) return -1;
        return stack[top];
    }
}