/*
#include<stdio.h>
int main() {
char input1[1000],input2[1000],rst[1000]={0};
int i,a,b,top1,top2,tmp=0,top3;
scanf("%s", input1);
scanf("%s", input2);
top1=strlen(input1)-1;
top2=strlen(input2)-1;
if(top1>top2){
a=top1;
b=top2;
top3=0;
}
else{
a=top2;
b=top1;
top3=0;
}
for(i=0;i<=b;i++){
rst[top3++]=(input1[top1]-'0'+input2[top2]-'0'+tmp)%10;
tmp=(input1[top1]-'0'+input2[top2]-'0'+tmp)/10;
top1--;
top2--;
}
for(i=a;i>b;i--){
if(top1<top2){
rst[top3++]=(input2[top2]-'0'+tmp)%10;
tmp=(input2[top2]-'0'+tmp)/10;
top2--;
}
else{
rst[top3++]=(input1[top1]-'0'+tmp)%10;
tmp=(input1[top1]-'0'+tmp)/10;
top1--;
}
}
if(tmp==1){
printf("1");
}
for(i=top3-1;i>=0;i--){
printf("%d",rst[i]);
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
int i,top1,top2;
char a[200]={0},b[200]={0},rst[200]={0};
scanf("%s %s",a,b);
top1=strlen(a);
top2=strlen(b);
if(top1!=top2){
for(i=a)
}
}
*/
#include<stdio.h>
#include<string.h>
int main()
{
int top=0,i,j,cnt=0,tmp1=0,tmp2=0,rst=0,on=0;
char stack[500]= {0};
scanf("%s",stack);
for(i=0; i<strlen(stack); i++)
{
if(stack[top++]=='('||stack[top++]=='[')
{
cnt++;
tmp1=top;
}
else
{
cnt--;
}
if(cnt==0)
{
if(top-tmp1>1)
{
on=0;
if(stack[top]=='(')
{
tmp2=2;
on++;
}
else
{
tmp2=3;
on++;
}
}
else
{
if(on!=0)
{
if(stack[tmp1]=='(')
{
rst+=(2*tmp2);
}
else
{
rst+=(3*tmp2);
}
}
else
{
if(stack[tmp1]=='(')
{
rst+=2;
}
else
{
rst+=3;
}
}
}
for(j=0; stack[top+i]==')'||stack[top+i]==']'; j++)
{
if(stack[top+i]=='('||stack[top+i]=='[')
{
top+=i;
}
}
}
}
printf("%d",rst);
return 0;
}