#include <bits/stdc++.h>
int main() {
  char a[10010];
  int angka = 1, target = 10, panjang = 1, index;
  for (int length = 0; length < 10000;) {
    int temp = angka, temp2 = panjang;
    while (temp) {
      a[length + temp2] = temp % 10 + '0';
      temp /= 10;
      temp2--;
    }
    length += panjang;
    angka++;
    if (angka == target) {
      target *= 10;
      panjang++;
    }
  }
  scanf("%d", &index);
  putchar(a[index]);
}
