module Boolean
	def -@
		!self
	end

	def *(other)
		self & other
	end	

	def +(other)
		self | other
	end	

	def >(other)
		!self | other
	end	
end

class TrueClass; include Boolean; end
class FalseClass; include Boolean; end

T = true
F = false

loop do
	s = gets.chomp
	break if s == ?#
	vars = s.scan(/[a-z]/).uniq

	s.sub!(?=, '==')
	s.sub!('->', '>')

	puts [?T, ?F].repeated_permutation(vars.size).all?{|assign|
		eval s.tr(vars.join, assign.join)	
	} ? 'YES' : 'NO'
end