#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mo = 1e9 + 7;
int main() {
  long long n;
  scanf("%lld", &n);
  long long t = 1;
  for (int i = (1); i <= (12); ++i) {
    if (n <= i * t * 9) {
      long long s = (n - 1) / i + t;
      int v = (n - 1) % i;
      for (int j = (i - 2); j >= (v); --j) s /= 10;
      return printf("%lld\n", s % 10), 0;
    }
    n -= i * t * 9;
    t *= 10;
  }
}
