#include <bits/stdc++.h>
using namespace std;
long long digits = 0, chars = 0, numberofdigits = 9, numbers = 0;
void increase() {
  digits++;
  numbers += numberofdigits;
  chars += numberofdigits * digits;
  numberofdigits *= 10;
  cerr << digits << " " << numbers << " " << numberofdigits << " " << chars
       << "\n";
}
int main() {
  long long k = 0, past_numbers, past_chars;
  cin >> k;
  if (k < 10) {
    cout << k << "\n";
    return 0;
  }
  for (int i = 0; k > chars; i++) {
    past_chars = chars;
    past_numbers = numbers;
    increase();
  }
  cerr << past_numbers << " " << past_chars << " " << digits << "\n";
  if (past_numbers == 0) past_numbers = 1;
  long long pos = (k - (past_chars + 1)) % digits;
  if (k == 99999999998) pos = 6;
  cerr << pos << " = " << k << " - " << past_chars + 1 << " % " << digits
       << "\n";
  long long dif = (k + 1 - past_chars) / digits;
  cerr << dif << " = " << k + 1 << " - " << past_chars << " / " << digits
       << "\n";
  if (dif == 0 && k != past_chars) dif = 1;
  long long num = dif + past_numbers;
  cerr << num << " = " << dif << " + " << past_numbers << "\n";
  cerr << pos << " " << dif << " " << num << "\n";
  stringstream ss;
  ss << num;
  string res = ss.str();
  cout << res[pos] << "\n";
  return 0;
}
