#include <bits/stdc++.h>
using namespace std;
long long qpow(long long x, long long y) {
  long long res = 1;
  for (; y; y >>= 1, x = x * x)
    if (y & 1) res = x * res;
  return res;
}
int main() {
  long long n, tot = 9;
  cin >> n;
  long long m = n;
  if (n < 10) return printf("%d\n", n) * 0;
  n -= 9;
  long long x = 9, r;
  for (int i = 2;; i++) {
    x *= 10;
    if (n - x * i <= 0) {
      r = i;
      break;
    }
    n -= x * i;
    tot += x * i;
  }
  long long y = n / r + (n % r != 0), z = qpow(10, r - 1) + y - 1,
            c = (m - tot) % r;
  int a[105], len = 0;
  while (z) {
    a[++len] = z % 10;
    z /= 10;
  }
  if (c == 0) c = r;
  c = r - c + 1;
  cout << a[c] << '\n';
  return 0;
}
