#include <bits/stdc++.h>
using namespace std;
long long k, to = 9, ti = 0, num[100000];
int main() {
  cin >> k;
  while (1) {
    ++ti;
    if (k - to * ti >= 0)
      k = k - to * ti;
    else
      break;
    to *= 10;
  }
  if (!k) {
    cout << 9;
    return 0;
  }
  if (!(k % ti)) {
    long long q = pow(10, ti - 1) + k / ti - 1;
    cout << q % 10;
    return 0;
  }
  long long sum = k / ti * ti;
  long long q = pow(10, ti - 1) + k / ti, pos = 0;
  while (q) num[++pos] = q % 10, q /= 10;
  k = k - k / ti * ti;
  cout << num[pos - k + 1];
}
