Let's write all the positive integer numbers one after another from 1 without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...

Your task is to print the k-th digit of this sequence.

Input

The first and only line contains integer k (1 ≤ k ≤ 10000) — the position to process (1-based index).

Output

Print the k-th digit of the resulting infinite sequence.

Examples

Input


7


Output


7


Input


21


Output


5
#include <bits/stdc++.h>
using namespace std;
inline long long exp(long long x, long long n) {
  long long r = 1;
  x = x % 1000000007;
  while (n) {
    if (n % 2) r = (r * x) % 1000000007;
    x = (x * x) % 1000000007;
    n = n / 2;
  }
  return r;
}
inline long long mmi(long long a) {
  return exp(a, 1000000007 - 2) % 1000000007;
}
inline long long fact(long long n) {
  long long res = 1;
  for (long long i = 1; i < (n + 1); ++i) {
    res = (res * i) % 1000000007;
  }
  return res;
}
inline long long inv_fact(long long n) {
  long long par = fact(n);
  long long res = mmi(par);
  return res;
}
struct triplet {
  long long a, b, c;
};
bool operator<(const triplet &t1, const triplet &t2) {
  if (t1.a < t2.a) return true;
  if (t1.a == t2.a && t1.b < t2.b) return true;
  if (t1.a == t2.a && t1.b == t2.b && t1.c < t2.c) return true;
  return false;
}
pair<long long, pair<long long, long long> > ex_gcd(long long a, long long b) {
  if (b == 0) {
    return make_pair(a, make_pair(1, 0));
  }
  pair<long long, pair<long long, long long> > p = ex_gcd(b, a % b);
  long long gcd = p.first;
  long long x1 = p.second.first;
  long long y1 = p.second.second;
  long long x = y1;
  long long y = x1 - (a / b) * y1;
  return make_pair(gcd, make_pair(x, y));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  long long ans;
  long long k = n;
  if (k > 9) {
    k -= 9;
  } else {
    ans = 0 + k;
    cout << ans << "\n";
    return 0;
  }
  if (k > 2 * 90) {
    k -= 2 * 90;
  } else {
    long long p = (k + 1) / 2;
    long long no = 9 + p;
    long long dig = k % 2;
    if (dig == 0)
      cout << no % 10 << "\n";
    else
      cout << no / 10 << "\n";
    return 0;
  }
  if (k > 3 * 900) {
    k -= 3 * 900;
  } else {
    long long p = (k + 2) / 3;
    long long no = 99 + p;
    long long dig = k % 3;
    if (k % 3 == 0)
      cout << no % 10 << "\n";
    else if (dig == 1)
      cout << no / 100 << "\n";
    else {
      cout << (no / 10) % 10 << "\n";
    }
    return 0;
  }
  if (k > 4 * 9000) {
    k -= 4 * 9000;
  } else {
    long long p = (k + 3) / 4;
    long long no = 999 + p;
    long long dig = k % 4;
    if (dig == 0) {
      cout << no % 10 << "\n";
    } else if (dig == 1) {
      cout << no / 1000 << "\n";
    } else if (dig == 2) {
      cout << (no / 100) % 10 << "\n";
    } else {
      cout << (no / 10) % 10 << "\n";
    }
    return 0;
  }
}
