(function(input) {
  'use strict';
  input.split("\n").some(function(line) {
    var number = parseInt(line, 10)
    while (number <= 999) {
      if (number % 111 == 0) {
        console.log(number)
        break
      } else {
        number += 1
      }
    }
  })
})(require('fs').readFileSync('/dev/stdin', 'utf8'))
