#include <bits/stdc++.h>
using namespace std;
long long int k;
string toString(long long int n) {
  stringstream second;
  second << n;
  string ret = second.str();
  return ret;
}
void func() {
  long long int t = 1, res = 9, cnt = 1, totDigit = 0, sum = 0,
                LastTotDigit = 0, LastSum = 0;
  while (1) {
    res = 9 * t;
    totDigit += (res * cnt);
    sum += res;
    if (totDigit >= k) {
      long long int dif = k - LastTotDigit;
      long long int q = dif / cnt;
      long long int r = dif % cnt;
      long long int num = LastSum + q;
      if (r) num++;
      string st = toString(num);
      cout << st[r = (r == 0) ? cnt - 1 : r - 1] << endl;
      return;
    }
    t = t * 10;
    cnt++;
    LastTotDigit = totDigit;
    LastSum = sum;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> k;
  func();
  return 0;
}
