#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long l = 1;
  long long f = 1;
  long long k = l * f * 9;
  while (k < n) {
    n -= k;
    l++;
    f *= 10;
    k = l * f * 9;
  }
  long long x;
  long long r;
  x = n / l;
  r = n % l;
  long long num = 1;
  for (long long i = 0; i < l; i++) num *= 10;
  num /= 10;
  num += x - 1;
  if (r == 0) {
    cout << num % 10;
  } else {
    num++;
    r = l - r;
    while (r--) {
      num /= 10;
    }
    cout << num % 10;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
