#include <bits/stdc++.h>
using namespace std;
long long a, k, tot, b, w, ans, f;
int main() {
  scanf("%lld", &k);
  b = 9;
  f = 1;
  while (tot < k) {
    w += 1;
    tot += (w * b);
    b *= 10;
    f *= 10;
  }
  b /= 10, tot -= (b * w), f /= 10;
  f += (k - tot + w - 1) / w - 1;
  tot += ((k - tot + w - 1) / w) * w;
  for (register int i = 1; i <= tot - k; i += 1) f /= 10;
  ans = f % 10;
  printf("%d", ans);
  return 0;
}
