#include <bits/stdc++.h>
using namespace std;
long long int find(long long int n) {
  long long int numDigits = 1 + floor(log10(n));
  long long int sum = 0, num = pow(10, numDigits - 1) - 1;
  for (long long int d = 1; d < numDigits; d++) {
    sum += d * 9ll * pow(10, d - 1);
  }
  sum += numDigits * (n - num);
  return sum;
}
long long int search(long long int k, long long int hi, long long int lo) {
  long long int mid = (hi + lo) / 2, num = find(mid);
  long long int currDigits = 1 + floor(log10(mid));
  long long int diff, numBefore = num - currDigits;
  if (num == k) {
    return mid % 10;
  }
  if (num > k && numBefore < k) {
    diff = num - k;
    while (diff--) mid = mid / 10;
    return mid % 10;
  }
  if (num > k) {
    hi = mid - 1;
    return search(k, hi, lo);
  }
  if (num < k) {
    lo = mid + 1;
    return search(k, hi, lo);
  }
}
int main() {
  long long int k, hi, lo, mid, ans;
  cin >> k;
  lo = 1;
  hi = pow(10ll, 12);
  ans = search(k, hi, lo);
  cout << ans;
  return 0;
}
