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