#include <bits/stdc++.h>
using namespace std;
long long calc(long long n) {
  long long ret = 0, i = 1, pw = 10;
  for (; i < to_string(n).size(); i++, pw *= 10) {
    ret += i * (pw - pw / 10);
  }
  ret += i * (n - pw / 10 + 1);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  long long k;
  cin >> k;
  long long l = 0, r = 1e18, ans = 0;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (k > calc(mid)) {
      l = mid + 1;
    } else {
      ans = mid;
      r = mid;
    }
  }
  cout << to_string(ans)[k - calc(ans - 1) - 1] << endl;
}
