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