function main = (input) => {
  if(input<10){
	console.log(input);
  }else if(input<100){
    concole.log(9);
  }else if(input<1000){
    concole.log(9+input-99);
  }
}
 
main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));