function main(input) {
  const N = parseInt(input, 10);
  let ans;
  
  for (let i = 111; i <= 999; i+=111) {
    if (N <= i) {
      ans = i;
      break;
    }
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));