Problem:
Score : 200 points

Problem Statement

Given is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).

Constraints

1 \leq N \leq 10^5

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of positive integers less than or equal to N that have an odd number of digits.

Sample Input 1

11

Sample Output 1

9

Among the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \ldots, 9.

Sample Input 2

136

Sample Output 2

46

In addition to 1, 2, \ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \ldots, 136.

Sample Input 3

100000

Sample Output 3

90909

Solution in JavaScript (node.js v5.12) (judge verdict: Wrong Answer)

// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input;
  var N = String(input);
  var result = 0;
  var splitN = N.split('');
  var kisuNum = '';

  if(splitN.length%2 === 0){
    for(var i = 0; i < splitN.length; i++) {
      if(i%2 === 0){
        kisuNum = kisuNum + '0'
      }
      else{
        kisuNum = kisuNum + '9'
      }
    }
    
    result = Number(kisuNum);
  }
  else if(splitN.length === 1){
    result = Number(splitN[0]);
  }
  else{
    for(var i = 0; i < splitN.length; i++) {
      if((splitN.length-i)%2 === 0){

      }
      else{
        if(i != 0){
            result = result + 9 * Math.pow(10, splitN.length-i-1);
        }
        else if((splitN[i] - 1) === 0){
          result = result + Number(N) - (Number(splitN[i])) * Math.pow(10, splitN.length-i-1) + 1;
        }
        else{
          result = result + (Number(splitN[i])-1) * Math.pow(10, splitN.length-i-1) + 1;
          result = result + Number(N) - (Number(splitN[i])) * Math.pow(10, splitN.length-i-1);
        }
      }
    }
  }

  console.log(result)
 }
 //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));