#include <bits/stdc++.h>
using namespace std;
long long int INF = 1e9 + 5;
long long int mod = 998244353;
long long int pM(long long int a, long long int b) {
  long long int ans = 1;
  while (b) {
    if (b & 1) {
      ans = (ans * a);
    }
    a = (a * a);
    b >>= 1;
  }
  return ans;
}
long long int find(long long int x) {
  long long int ans = 0, p = 1;
  for (long long int i = 1; i <= x; i++) {
    ans += 9 * p * i;
    p *= 10;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int pos;
  cin >> pos;
  long long int l = 0, r = 12;
  while (l + 1 < r) {
    long long int x = l + (r - l) / 2;
    if (find(x) <= pos) {
      l = x;
    } else {
      r = x;
    }
  }
  if (find(l) == pos) {
    cout << 9 << "\n";
  } else {
    pos -= find(l);
    l++;
    long long int no = pM(10, l - 1) + (pos / l) - 1;
    if (pos % l) {
      no++;
      for (long long int i = 0; i < l - pos % l; i++) {
        no /= 10;
      }
    }
    cout << no % 10 << "\n";
  }
}
