#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  string s;
  for (int i = 1; i <= 10000; i++) {
    int p = i;
    string s1;
    while (p > 0) {
      s1 += char(p % 10 + 48);
      p /= 10;
    }
    reverse(s1.begin(), s1.end());
    s += s1;
  }
  cout << s[k - 1];
  return 0;
}
