s = gets.chomp.split("")
arr = [0, 0, 0, 0]
s.each{|c|
    case c
    when "K" then arr[0] += 1
    when "U" then arr[1] += 1
    when "P" then arr[2] += 1
    when "C" then arr[3] += 1
    end
}
puts arr.min
