#include <bits/stdc++.h>
using namespace std;
const long long MAX = 5202;
void solve() {
  long long k;
  scanf("%lld", &k);
  long long cnt = 1;
  long long d = 1;
  while (k > cnt * 9 * d) {
    k -= cnt * 9 * d;
    cnt++;
    d *= 10;
  }
  long long num = ceil(1.0 * k / cnt) + (d - 1);
  k = (k - 1) % cnt + 1;
  for (long long i = 0; i < cnt - k; i++) {
    num /= 10;
  }
  long long ans = num % 10;
  printf("%lld", ans);
}
int main() {
  solve();
  return 0;
}
