#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const long long MOD = 1e9 + 7;
const long long oo = 1e18 + 7;
void solve() {
  long long k;
  cin >> k;
  long long s = 0, f = 0, c = 0;
  while (1) {
    s = f + 1;
    f = f * 10 + 9;
    c++;
    if (k >= (f - s + 1) * c) {
      k -= (f - s + 1) * c;
    } else {
      long long x = k / c;
      long long y = k % c;
      if (!y) {
        x--;
        y = c;
      }
      long long t = s + x;
      vector<char> save;
      for (int i = 1; i <= c; i++) {
        save.push_back(t % 10 + '0');
        t /= 10;
      }
      cout << save[c - y];
      return;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(10);
  solve();
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
