#include <iostream>
#include<string>
#include <stack>
using namespace std;


//조건 3개
//스택에서 pop 하면서 ')'갯수보다 '('가 많아지면 탈락
//']'뽑은 이후에 '(' 나오거나, ')' 이후에 '['나오면 게임 끝
//'('와 ')'의 갯수가 동일해야함 


bool isVps(stack<char>& ref)
{
    int sRightN = 0, sLeftN = 0; //소괄호 갯수
    int bRightN = 0, bLeftN = 0; //대괄호 갯수
    char beforC = ' '; //이전 문자
    char nowC = ' '; //현재 문자


    int stackSize = ref.size();

    for (int i = 0; i < stackSize; i++) //스택에서 pop 하면서 ')'갯수보다 '('가 많아지면 탈락
    {

        beforC = ref.top();


        if (ref.top() == ')')
            sRightN++;
        else if (ref.top() == '(')
            sLeftN++;
        else if (ref.top() == ']')
            bRightN++;
        else if (ref.top() == '[')
            bLeftN++;

        if (sLeftN > sRightN)
            return false;
        else if (bLeftN > bRightN)
            return false;
        else
        {
            ref.pop();
            if(!ref.empty())
                nowC = ref.top();
        }

        if ((nowC == '(' && beforC == ']') || (nowC == '[' && beforC == ')')) //']'뽑은 이후에 '(' 나오거나, ')' 이후에 '['나오면 게임 끝
            return false;

    }

    if (sLeftN == sRightN && bLeftN == bRightN) //'('와 ')'의 갯수가 동일해야함
        return true;
    else
        return false;
}

//반례
//()
//.

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    string line;
    stack<char> vpsContainer;


    while (true)
    {

        while (true) //문장의 마지막 '.'을 받을 때까지 계속 스택에 넣음
        {
            getline(cin, line);
            for (char c : line)
                if (c == '.')
                    goto out;
                else if (c == '(' || c == ')' || c == '[' || c == ']')
                    vpsContainer.push(c);

        }

    out:

        if (line == ".")
            break;


        if (isVps(vpsContainer))
            cout << "yes" << "\n";
        else
            cout << "no" << "\n";

        while (!vpsContainer.empty())//스택 컨터이너 비우기
        {
            vpsContainer.pop();
        }

    }


    return 0;
}
