#include <bits/stdc++.h>
using namespace std;
long long n, x;
int main() {
  scanf("%lld", &n);
  x = 9;
  for (int i = 1;; n -= i++ * x, x *= 10)
    if (n <= i * x) {
      for (x = x / 9 + --n / i; ++n % i; x /= 10)
        ;
      return printf("%lld\n", x % 10), 0;
    }
  return 0;
}
