#include <stdio.h>
int main()
{
int c, lbraces=0, rbraces=0, lb='{', rb='}';
while ((c=getchar()) != EOF)
{
putchar(c);
while (c==lb || c==rb)
{
if (c==lb) lbraces++;
if (c==rb) rbraces++;
if (rbraces > lbraces)
{
printf("??");
rbraces--;
}
c=0;
}
}
if (lbraces > rbraces)
printf(" %d missing ",lbraces-rbraces);
for (;lbraces > rbraces; lbraces--)
putchar(rb);
return 0;
}