#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 2e5 + 5;
const int MOD = 1e9 + 7;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
ll k;
ll ps1[19], ps2[19];
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s =
      "a12345678910111213141516171819202122232425262728293031323334353637383940"
      "414243444546474849505152535455565758596061626364656667686970717273747576"
      "777879808182838485868788899091929394959697989910010110210310410510610710"
      "810911011111211311411511611711811912012112212312412512612712812913013113"
      "213313413513613713813914014114214314414514614714814915015115215315415515"
      "615715815916016116216316416516616716816917017117217317417517617717817918"
      "018118218318418518618718818919019119219319419519619719819920020120220320"
      "420520620720820921021121221321421521621721821922022122222322422522622722"
      "822923023123223323423523623723823924024124224324424524624724824925025125"
      "225325425525625725825926026126226326426526626726826927027127227327427527"
      "6277278279280";
  ps1[1] = 9;
  for (ll i = 2; i <= 18; i++) {
    ll x = (9 * pow(10, i - 1)) * i;
    ps1[i] = ps1[i - 1] + x;
  }
  ps2[1] = 9;
  for (ll i = 2; i <= 18; i++) {
    ps2[i] = ps2[i - 1] * 10 + 9;
  }
  cin >> k;
  ll x = 0;
  for (ll i = 1; i <= 18; i++) {
    if (k >= ps1[i]) {
      x++;
    } else {
      break;
    }
  }
  ll y = k - ps1[x];
  ll start = ps2[x];
  ll add = y / (x + 1);
  ll num = start + add;
  ll next = num + 1;
  ll rem = y % (x + 1);
  string s1 = to_string(num);
  string s2 = to_string(next);
  char ans;
  if (rem == 0) {
    ans = s1[s1.size() - 1];
  } else {
    ans = s2[-1 + rem];
  }
  cout << ans << "\n";
  return 0;
}
