#include<stdio.h>
#include<string.h>
int main(){
    char s[105],st[105],int top=-1;
    scanf("%s",s);
    for(int i=0;s[i];i++){
        char c=s[i];
        if(c=='('||c=='{'||c=='[')str[++top]=c;
        else if(c==')'||c=='}'||c==']'){
            if(top==-1||(c==')'&&st[top]!='(')||(c=='}'&&st[top]!='{')||(c==']'&&st[top!='[')){
                printf("Not Balanced");
                return 0;
            }
            top--;
        }
    }
    printf(top==-1?"Balanced":"Not Balanced");
    return 0;
}