#include <bits/stdc++.h>
using namespace std;
long long T = 0, n, t, a;
long long mu10(int b) {
  long long c = 1;
  for (int i = 1; i <= b; i++) c = c * 10;
  return c;
}
long long solve(long long c) {
  int m = 1;
  long long T = 0;
  while (T < c) {
    T += ((mu10(m)) - (mu10(m - 1))) * m;
    a = mu10(m) - 1;
    m++;
  }
  m -= 1;
  long long b = (T - c);
  long long d = a - (b / m);
  if (b % m == 0)
    return d % 10;
  else {
    d /= mu10(b % m);
    return d % 10;
  }
}
int main() {
  cin >> n;
  cout << solve(n);
  return 0;
}
