const n = Number(input[0])
function main(n){
  if(Number.isInteger(n / 111)){
  	console.log(n)
  }else{
 	console.log((Math.floor(n / 111) + 1)* 111)
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))