require 'set'

s = 'ABC'
reached = Set[s]
stack = [s]

target = gets.chomp
ok = false
until stack.empty?
    g = stack.pop
    (?A..?C).each do |l|
        t = g.gsub(l, s)
        next if t.size > target.size
        next if reached.include?(t)
        stack << t
        reached << t
        if t == target
            ok = true
            stack = []
            break
        end
    end
end

puts ok ? 'Yes' : 'No'