now_ABC = gets.chomp!.to_i
next_ABC = now_ABC.to_s
flag = 0
count = 0

first_char = next_ABC[0]
next_ABC.chars do |c|
  if c !=  first_char then break end
  count += 1
  if count == next_ABC.length then
    flag = 1
  end
end
count = 0
while flag == 0 do
  first_char = next_ABC[0]
  count = 0
  next_ABC.chars do |c|
    if c != first_char then break end
    count += 1
    if count == next_ABC.length then
      flag = 1
    end
  end
  next_ABC = next_ABC.to_i
  if flag == 0 then next_ABC += 1 end
  next_ABC = next_ABC.to_s
end




puts next_ABC.to_i