#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  long long k;
  cin >> k;
  long long l = 1, r = 1e12;
  long long a[13];
  a[0] = 0;
  for (long long i = 1; i <= 12; i++) {
    a[i] = pow(10ll, i) - pow(10ll, i - 1);
    a[i] = i * a[i] + a[i - 1];
  }
  while (l != r) {
    long long m = (l + r) / 2;
    long long rghm = log10(m) + 1;
    long long ghabl = a[rghm - 1] + (m - pow(10ll, rghm - 1)) * rghm;
    if (ghabl >= k) {
      r = m - 1;
    } else if (ghabl + rghm < k) {
      l = m + 1;
    } else {
      l = r = m;
    }
  }
  long long rghm = log10(l) + 1;
  long long ghabl = a[rghm - 1] + (l - pow(10ll, rghm - 1)) * rghm;
  long long ind = k - ghabl - 1;
  string s = to_string(l);
  cout << s[ind] << "\n";
}
