#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a = 9, b = 9, c = 1, d, e, cnt;
  string g;
  cin >> n;
  while (n > b * c) {
    n = n - (b * c);
    b = b * 10;
    c++;
  }
  cnt = b / 9 + (n - 1) / c;
  n = (n - 1) % c;
  g = to_string(cnt);
  cout << g[n] << "\n";
}
