require 'set'

target = gets.chomp
s = 'ABC'
ok = false
if target == s
    reached = Set[s]
    stack = [s]

    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
else
    ok = true
end


puts ok ? 'Yes' : 'No'