#include <bits/stdc++.h>
using namespace std;
void solve(long long now, long long wz) {
  vector<int> fj;
  while (now) {
    fj.push_back(now % 10);
    now /= 10;
  }
  printf("%d\n", fj[fj.size() - wz]);
}
int main() {
  long long sum = 0;
  long long x = 90;
  long long xxx = 1e12;
  vector<pair<int, long long> > ss;
  for (int i = 1; i < 20; ++i) {
    if (i == 1)
      sum = 9;
    else {
      sum += x * i;
      x *= 10;
    }
    ss.push_back(make_pair(i, sum));
    if (sum >= xxx) break;
  }
  long long k;
  scanf("%lld", &k);
  if (k < 10) {
    cout << k << endl;
    return 0;
  }
  int pos;
  for (pos = 0; pos < ss.size(); ++pos)
    if (ss[pos + 1].second >= k) break;
  k -= ss[pos].second;
  vector<long long> powT;
  powT.push_back(0);
  long long T = 0;
  for (int i = 1; i <= 12; ++i) {
    powT.push_back(T);
    if (i == 1) T = 1;
    T *= 10;
  }
  long long now = (k - 1) / ss[pos + 1].first + powT[ss[pos + 1].first];
  long long use = (now - powT[ss[pos + 1].first]) * ss[pos + 1].first;
  solve(now, k - use);
  return 0;
}
