#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  long long k, n, m, x = 10;
  int i = 1;
  cin >> k;
  k -= 9;
  if (k <= 0) {
    k = k + 9;
    cout << k;
    exit(0);
  }
  while (++i) {
    k -= 9 * i * x;
    if (k <= 0) {
      k += 9 * i * x;
      n = k / i;
      m = k % i;
      n = x + n;
      if (m == 0) n -= 1;
      ostringstream s;
      s << n;
      string s1 = s.str();
      if (m == 0)
        cout << s1[i - 1];
      else
        cout << s1[m - 1];
      exit(0);
    }
    x = x * 10;
  }
}
