#include <bits/stdc++.h>
using namespace std;
char solve(long long int k) {
  long long int digit = 1;
  while (k > 0) {
    k = k - (9 * pow(10, digit - 1) * digit);
    digit++;
  }
  digit--;
  k = k + (9 * pow(10, digit - 1) * digit);
  long long int pos = ceil((k / (long double)digit));
  long long int num = pow(10, digit - 1) + pos - 1;
  string ans = to_string(num);
  long long int index = (((k % digit) - 1) + digit) % digit;
  return ans[index];
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int k;
  cin >> k;
  cout << solve(k);
}
