#include <bits/stdc++.h>
using namespace std;
int main() {
  long long num, hand = 1, dt = 1;
  cin >> num;
  while (9 * hand * dt < num) {
    num -= 9 * hand * dt;
    dt++;
    hand *= 10;
  }
  hand += (num - 1) / dt;
  num = (num - 1) % dt + 1;
  while (dt-- > num) hand /= 10;
  cout << hand % 10 << endl;
  return 0;
}
