#include <bits/stdc++.h>
using namespace std;
string str(int x) {
  string ret = "";
  while (x > 0) {
    ret += (x % 10) + '0';
    x /= 10;
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s = "";
  for (int i = 1; i <= 10000; i++) {
    s += str(i);
  }
  int k;
  cin >> k;
  cout << s[k - 1] << endl;
  return 0;
}
