#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10000, MAXM = 50000;
int n, u, ar[MAXM];
void fun(vector<int> &v, int k) {
  while (k) {
    v.push_back(k % 10);
    k /= 10;
  }
  reverse(v.begin(), v.end());
}
int main() {
  cin >> n;
  for (int i = 1; i < MAXN; i++) {
    vector<int> tmp;
    fun(tmp, i);
    for (int j = 0; j < tmp.size(); j++) ar[u + j] = tmp[j];
    u += tmp.size();
  }
  cout << ar[n - 1];
}
