#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
bool compare(T x, U y) {
  return (abs(x - y) <= 1e-9);
}
const long long MOD = 1e9 + 7;
void solve() {
  long long k;
  cin >> k;
  long long sum = 0;
  long long ten = 1;
  long long dig = 0;
  while (1) {
    dig++;
    sum += 9 * ten * dig;
    if (sum >= k) break;
    ten *= 10;
  }
  if (sum == k)
    cout << 9;
  else {
    sum -= (9 * ten * dig);
    sum = k - sum;
    long long beg = ten - 1;
    beg += (sum / dig);
    if (sum % dig == 0)
      cout << beg % 10;
    else {
      beg++;
      long long pos = (dig - sum % dig);
      long long cnt = 0;
      while (beg) {
        if (cnt == pos) {
          cout << beg % 10;
          return;
        }
        cnt++;
        beg /= 10;
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
}
