#include <bits/stdc++.h>
using namespace std;
long long numLower(long long x) {
  long long bs = 10, numc = 1, total = 0;
  while (x > bs) {
    total += (bs - bs / 10) * numc;
    bs *= 10;
    numc++;
  }
  bs /= 10;
  total += (x - bs) * numc;
  return total;
}
string toString(long long x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
char solve(long long a) {
  long long add = 1, cur = 1;
  while (add) {
    if (numLower(add + cur) <= a) {
      cur += add;
      add *= 2;
    } else {
      add /= 2;
    }
  }
  a -= numLower(cur);
  string temp = toString(cur);
  return temp[a];
}
int main() {
  long long a;
  cin >> a;
  a--;
  cout << solve(a) << endl;
  return 0;
}
