#include <iostream>
using namespace std;
int main() {
int n, m, minus = 1;
cin >> n;
m = 1;
for (int a = 1; n> 0; a *= 10) {
for (int b = a; b < a*10; b++) {
if ((n - minus) < 0) {
cout << 0;
return 0;
}
if ((n - minus) == 0) {
cout << m;
return 0;
}
n-= minus;
m++;
}
minus++;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgaW50IG4sIG0sIG1pbnVzID0gMTsKICBjaW4gPj4gbjsKICBtID0gMTsKICBmb3IgIChpbnQgYSA9IDE7IG4+IDA7IGEgKj0gMTApIHsKICAgIGZvciAgKGludCBiID0gYTsgYiA8IGEqMTA7IGIrKykgewogICAgICBpZiAoKG4gLSBtaW51cykgPCAwKSB7CiAgICAgICAgY291dCA8PCAwOwogICAgICAgIHJldHVybiAwOwogICAgICB9CiAgICAgIGlmICgobiAtIG1pbnVzKSA9PSAwKSB7CiAgICAgICAgY291dCA8PCBtOwogICAgICAgIHJldHVybiAwOwogICAgICB9CiAgICAgIG4tPSBtaW51czsKICAgICAgbSsrOwogICAgfQogICAgbWludXMrKzsKICB9CiAgcmV0dXJuIDA7Cn0=