/*把为配对的左括号计数,然后遇到右括号的时候左括号就配对一个,
如果没有可以配对的,那么这个右括号是一定需要修改的,
这样一直到最后未配对的左括号数只需要修改一半即可完成配对
*/
#include<stdio.h>
#include<string.h>
int main()
{
    int i,cnt=0,ans,temp,l;
    char str[10000];
    while(gets(str))
    {
        if(str[0]=='-')break;
        ans=0,temp=0;
        l=strlen(str);
        for(i=0;i<l;i++)
        {
            if(str[i]=='{')
                temp++;
            else
            {
                if(temp>0)temp--;
                else
                {
                    ans++;temp++;
                }
            }
        }
        ans+=temp/2;
        printf("%d. %d\n",++cnt,ans);
    }
	return 0;
}