#include <bits/stdc++.h>
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
template <class t>
inline void writeln(t x) {
  write(x);
  putchar('\n');
  return;
}
template <class t>
inline void write_blank(t x) {
  write(x);
  putchar(' ');
  return;
}
long long n, len = 1, num = 1;
signed main() {
  read(n);
  while (1) {
    if (n < num * 9 * len) {
      num = num + n / len + (n % len > 0) - 1;
      n = len - (n % len ? n % len : len);
      while (n--) {
        num /= 10;
      }
      write(num % 10);
      return 0;
    } else {
      n -= num * 9 * len++;
      num *= 10;
    }
  }
  return 0;
}
