#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e8;
int main() {
  int k;
  scanf("%d", &k);
  string s = "";
  for (int i = 1; i <= 10000; i++) {
    string s1 = to_string(i);
    s += s1;
  }
  cout << s[k - 1] << "\n";
  return 0;
}
