S = gets.chomp counter = Hash.new(0) ans = 0 S.each_char do |s| ('A'..'Z').each do |c| next if s == c cnt = counter[c] next if cnt <= 1 ans += cnt * (cnt - 1) / 2 end counter[s] += 1 end puts ans