h = {}
gets.chomp.each_char do |c|
    h[c] ||= 0
    h[c] += 1
end
k = 0
until h.empty?
    seq = [h.keys.min]
    while h[seq[-1].next]
        seq << seq[-1].next
    end
    if seq.size >= 3
        k += 3
    else
        k += seq.size
    end
    seq.each do |c|
        h[c] -= 1
        h.delete(c) if h[c] == 0
    end
end
p k
