/*
3022 큰 수 뺄셈
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char a[101] = {}, b[101] = {}, result[101] = {};
int stack[101] = {};
int top = -1;
void push(int n)
{
top++;
stack[top] = n;
}
int pop()
{
if (top > -1) top--;
return stack[top + 1];
}
int cmp()
{
int lena = strlen(a), lenb = strlen(b);
if (lena != lenb) return (lena > lenb) ? 1 : -1;
return strcmp(a, b) >= 0 ? 1 : -1;
}
int main()
{
scanf("%s", a);
scanf("%s", b);
int sign = 1;
if (cmp() < 0)
{
char t[101] = {};
strcpy(t, a); strcpy(a, b); strcpy(b, t);
sign = -1;
}
int i, lenr = 0;
int lena = strlen(a);
int lenb = strlen(b);
for (i = 0; i < lena; i++)
{
push(a[i] - '0');
}
int borrow = 0;
for (i = lenb - 1; i >= 0; i--)
{
int x = pop();
int y = b[i] - '0';
int dif = x - y - borrow;
if (dif < 0)
{
dif = dif + 10;
borrow = 1;
}
else
{
borrow = 0;
}
result[lenr++] = dif + '0';
}
while (top >= 0)
{
int x = pop() - borrow;
if (x < 0)
{
x = x + 10;
borrow = 1;
}
else
{
borrow = 0;
}
result[lenr++] = x + '0';
}
while (lenr > 1 && result[lenr - 1] == '0')
{
lenr--;
}
if (lenr == 1 && result[0] == '0')
{
sign = 1;
}
if (sign < 0)
{
printf("-");
}
for (i = lenr - 1; i >= 0; i--)
{
printf("%c", result[i]);
}
return 0;
}
*/
/*
4833 쇠 막대기
#include <stdio.h>
int stack[100001]={};
int top = -1;
void push(int a)
{
top++;
stack[top]=a;
}
char pop()
{
if(top>-1)
{
top--;
}
return stack[top+1];
}
int main()
{
char c[100001]={};
int i, pipe=0, sum=0;
scanf("%s",c);
for(i=0;c[i]!=0;i++)
{
if(c[i]=='(')
{
pipe++;
push(c);
}
else
{
pop();
pipe--;
if(c[i-1]=='(')
{
sum=sum+pipe;
}
else
{
sum++;
}
}
}
printf("%d",sum);
return 0;
}
*/
//4624 괄호의 값 - 여는 괄호 나오면 푸시 닫는 괄호 나오면 팝 곱한 값을 다시 스택에 넣어서 마지막에 더함
#include <stido.h>
int stack[31]={};
int top=-1;
void push(int x)
{
top++;
stack[top]=x;
}
char pop()
{
if(top>-1)
{
top--;
}
return stack[top+1];
}
int main()
{
char c[31]={};
int small=0, big=0;
int cal=1;
scanf("%s",c);
for(int i=0;c[i]!=0;i++)
{
if(c[i]=='(')
{
push(c);
small++;
cal=cal*2;
}
if(c[i]=='[')
{
push(c);
big++;
cal=cal*3;
}
if(c[i]==')')
{
pop();
}
if(c[i]==']')
{
pop();
}
}
return 0;
}



