#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, x = 9;
  cin >> k;
  for (int i = 1;; k -= i++ * x, x *= 10)
    if (k <= i * x) {
      for (x = x / 9 + --k / i; ++k % i; x /= 10)
        ;
      return cout << x % 10, 0;
    }
}
