#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long k;
  cin >> k;
  int digit = 1;
  while (1) {
    if (k <= 9 * pow(10, digit - 1) * digit)
      break;
    else {
      k -= 9 * pow(10, digit - 1) * digit;
      digit++;
    }
  }
  long long at, num, at_d[15];
  at = (k - 1) / digit + pow(10, digit - 1);
  num = (k - 1) % digit;
  for (int i = 0; at != 0; i++) {
    at_d[digit - 1 - i] = at % 10;
    at /= 10;
  }
  cout << at_d[num] << endl;
}
