#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k;
  cin >> k;
  long long digits = 1, nd = 9;
  while (k > digits * nd) {
    k -= digits * nd;
    digits++;
    nd *= 10;
  }
  long long start = nd / 9;
  long long n = start + (k - 1) / digits;
  string number = to_string(n);
  int d = (k - 1) % digits;
  cout << number[d] << endl;
  return 0;
}
