#include <bits/stdc++.h>
using namespace std;
string toString(int n) {
  string str = "";
  while (n) {
    str += n % 10 + '0';
    n /= 10;
  }
  reverse(str.begin(), str.end());
  return str;
}
int main() {
  string s = "";
  for (auto i = (1); i <= (10000); ++i) {
    string t = toString(i);
    s += t;
  }
  int n;
  scanf("%d", &n);
  printf("%c\n", s[n - 1]);
  return 0;
}
