# frozen_string_literal: true s = gets.chomp.chars.group_by { |i| i }.map { |_, v| v.size } puts [s[0] - 1, s[1]].min