while line = gets and line.chomp! != '.'
    stack = []
    ans = true
    line.each_char do |c|
        if ['(', '['].include? c
            stack.push c
        end
        if [')', ']'].include? c
            if stack.empty? or stack.pop != {')' => '(', ']' => '['}[c]
                ans = false
                break
            end
        end
    end
    puts (if ans and stack.empty?
            'yes'
        else
            'no'
        end)
end