#include <stdio.h>
#include<string.h>
#include<stdbool.h>
#define max 10005
int main() {
    char a[max];
    char stack[max];
    int top=0;
    bool yes=true;
    scanf("%s",a);
    int m=strlen(a);
    for(int i=0;i<m;i++){
        if(a[i]=='('||a[i]=='['){
            stack[top++]=a[i];
        }
        else if(a[i]==')'){
            if(top==0||stack[top-1]!='('){
                yes=false;
                break;
            }
            top--;
        }
        else if(a[i]==']'){
            if(top==0||stack[top-1]!='['){
                yes=false;
                break;
            }
            top--;
        }

    }
    if(top!=0){
        yes=false;
    }
    if(yes){
        printf("true\n");
        return 0;
    }
        printf("false\n");
    return 0;
}