#include <bits/stdc++.h>
using namespace std;
long long inf1 = 1e18;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long k;
  cin >> k;
  long long a = 1;
  long long b = 1;
  while (1) {
    if (k - 9 * a * b < 0) break;
    k -= 9 * a * b;
    a++;
    b *= 10;
  }
  long long x = k - (k / a) * a;
  k /= a;
  k += b;
  if (x == 0)
    cout << (k - 1) % 10;
  else {
    string my_val = std::to_string(k);
    cout << my_val[x - 1];
  }
}
