def f(s)
    return s == 'ABC' if s.size <= 3
    x = s.gsub('ABC', 'X')
    a = %w(A B C)
    a.delete(?A) if x =~ /A/
    a.delete(?B) if x =~ /B/
    a.delete(?C) if x =~ /C/
    return a.any? {|c| f(x.gsub(?X, c))}
end

s = gets.chomp
puts f(s) ? 'YES' : 'NO'
