#include <bits/stdc++.h>
using namespace std;
void desperate_optimization(int precision) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tc;
  vector<pair<long long, long long> > rd;
  vector<long long> f;
  tc = 1;
  while (tc--) {
    long long n;
    cin >> n;
    long long cnt = 0;
    for (long long i = 1, x = 1;; i++, x *= 10) {
      cnt += 9 * x * i;
      if (cnt >= n) {
        long long d = n - (cnt - 9 * x * i);
        long long ans = x + d / i;
        long long p = d % i;
        if (!p) p = i, ans--;
        p = i - p;
        p++;
        long long fans;
        while (p--) {
          fans = ans % 10;
          ans /= 10;
        }
        cout << fans;
        return 0;
      }
    }
  }
  return 0;
}
