#include <stdio.h>
#include <string.h>

int isMatching(char open, char close) {
    if (open =='(' && close == ')') return 1;
    if (open =='{' && close == '}') return 1;
    if (open =='[' && close == ']') return 1;
    return 0;
}
int main() {
    char s[101];
    scanf("%s", s);
    char stack[101];
    int top = -1;
    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;
            }
            top--;
        }
        }
        if (top == -1)
            printf("Balanced");
        else
            printf("Not Balanced");
            return 0;
}