n=gets.to_i
s=[n/100,(n%100-n%10)/10,n%10]
a=s.sort
t=a[1]
if a[0]==a[2]
  puts n

elsif s[0]==a[0]
  m=s[0]+1
  puts m*100+m*10+m

elsif (t*100+t*10+t)>n
 puts(t*100+t*10+t)
else
 t=a[2]
 puts (t*100+t*10+t)
end

