#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000000;   const int maxn = 100;   const int MAXN = 2750131;   long long T, n, m, i, j;   long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); }   long long g[200005];   int main() {     ios::sync_with_stdio(false);     long long a[20];     long long k = 1, s = 1, sum = 9;     for (i = 0; s < 1e12; i++) {       a[i] = s * sum * k;       s *= 10;       k++;     }     cin >> n;     if (n < 10) {       cout << n << endl;       return 0;     }     sum = 0;     i = 0;     k = 1;     s = 1;     long long m = n;     while (m > a[i]) {       m -= a[i];       i++;       k++;       s = pow(10, i);       sum = s - 1;     }     long long ans = (m) / k + sum;     if (m % k) {       ans++;     }     long long sk = m % k;     if (sk == 0) {       sk = k;     }     while (ans > 0) {       if (sk == k) {         cout << ans % 10 << endl;         break;       } else {         ans /= 10;         k--;       }     }     return 0;   }   