# frozen_string_literal: true def solve (S.chars .slice_when { _1 != _2 } .map(&:size) .each_cons(2) .map(&:min) .max || 0) * 2 end S = gets.chomp puts solve