T=!!0
F=!T
[T,F].map{|c|
class<<c
alias:%:==
def!=x
!self|x
end
end
}
until(s=gets.tr"-=>*+","!%=&|")=~/#/
v=s.scan(/[a-z]/).uniq
puts %w(T F).repeated_permutation(v.size).all?{|a|
eval s.tr v*'',a*''
}?'YES':'NO'
end