#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];
    }
}
}