#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a;
  for (int i = 1; i <= 10000; i++) {
    int f = i;
    int b[6];
    int c = 0;
    while (f != 0) {
      b[c] = f % 10;
      f /= 10;
      c++;
    }
    for (int j = 0; j < c; j++) a.push_back(b[c - j - 1]);
  }
  int k;
  cin >> k;
  k--;
  cout << a[k];
}
