#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 + 1e5;
long long n;
long long d[maxn], dd[maxn];
vector<int> g;
stack<int> second;
void tknp(long long k, long long cs, long long x, long long y) {
  long long l = x, r = y, ans = 0;
  if (n < cs)
    l = dd[cs - 1];
  else {
    while (l < r) {
      long long tg = (l + r + 1) / 2;
      if ((tg - x + 1) * cs <= n)
        l = tg;
      else
        r = tg - 1;
    }
    n -= (l - x + 1) * cs;
    if (n == 0) {
      cout << l % 10 << endl;
      return;
    }
    l++;
  }
  while (n > 0) {
    ans = l / dd[cs - 1];
    l %= dd[cs - 1];
    cs--;
    n--;
  }
  cout << ans << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  if (n < 10) {
    cout << n << endl;
    return 0;
  }
  g.resize(100);
  long long cs = 1, sl = 9;
  d[cs] = 9, dd[cs] = 10;
  while (d[cs] < n) {
    cs++;
    sl *= 10;
    d[cs] = d[cs - 1] + cs * sl;
    dd[cs] = dd[cs - 1] * 10;
  }
  n -= d[cs - 1];
  if (cs == 1) {
    cout << n << endl;
    return 0;
  }
  tknp(n, cs, dd[cs - 1], dd[cs] - 1);
  return 0;
}
