#include <bits/stdc++.h>
using namespace std;
int getDigit(long long number, long long index) {
  while (index--) number /= 10;
  return number % 10;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  if (n <= 9) {
    cout << n << endl;
    return 0;
  }
  long long digitCount = 1;
  long long numNumbers = 9;
  long long prev = 0;
  while (n > numNumbers * digitCount) {
    n -= numNumbers * digitCount;
    prev += numNumbers;
    numNumbers *= 10;
    digitCount++;
  }
  long long digitIndex = n % digitCount;
  long long numIndex = (n) / digitCount;
  if (digitIndex > 0) numIndex++;
  if (digitIndex == 0) digitIndex = digitCount;
  long long number = prev + 0 + numIndex;
  cout << getDigit(number, digitCount - digitIndex) << endl;
  return 0;
}
