def is_balanced?(line)
  brackets = []

  line.each do |char|
    case char
      when '('
        brackets.push(char)
      when ')'
        return false if brackets.pop != '('
      when '['
        brackets.push(char)
      when ']'
        return false if brackets.pop != '['
      else
        # pass
    end
  end

  return true
end

loop do
  line = gets.chomp.to_s.chars
  break if line.size == 1 && line[0] == '.'

  puts is_balanced?(line) ? 'yes' : 'no'
end