#include <bits/stdc++.h>
using namespace std;
const bool ready = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(12);
  return true;
}();
const double PI = acos(-1);
using ll = long long;
using pii = pair<ll, ll>;
using pdd = pair<double, double>;
using vd = vector<double>;
using vb = vector<bool>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
void solve() {
  ll n;
  cin >> n;
  ;
  ll ten = 1;
  ll cnt = 1;
  while (ten * 9 * cnt < n) {
    n -= ten * 9 * cnt;
    ten *= 10;
    cnt++;
  }
  ll nn = (n - 1) / cnt;
  ll dig = (n - 1) % cnt;
  ll num = ten + nn;
  vi d;
  while (num) {
    d.push_back(num % 10);
    num /= 10;
  }
  reverse((d).begin(), (d).end());
  cout << d[dig] << endl;
}
signed main() { solve(); }
