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