#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long long MOD = 12345678910;
const long double eps = 1e-13;
const int imax = INT_MAX;
vector<int> ans, p;
void pluss() {
  p[0]++;
  int f = 0;
  while (p[f] == 10) {
    if (f == p.size() - 1) p.push_back(0);
    p[f] = 0;
    f++;
    p[f] = p[f] + 1;
  }
}
int main() {
  cin.tie(0);
  ios_base ::sync_with_stdio(0);
  int k;
  cin >> k;
  p.push_back(0);
  while (ans.size() < k) {
    pluss();
    for (int i = p.size() - 1; i > -1; i--) ans.push_back(p[i]);
  }
  cout << ans[--k] << endl;
  return 0;
}
