#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long s = 1;
  long long c = 9;
  long long digit = 1;
  while (n > c * digit) {
    n = n - c * digit;
    digit++;
    s = s * 10;
    c = c * 10;
  }
  s = s + (n - 1) / digit;
  cout << to_string(s)[int((n - 1) % digit)] - '0';
}
