bool smaller(int x);
int find_number(int MAX)
{
    int l = 1, d = MAX, s, ps = 0;
    while (l < d)
    {
        s = l+(d-l)/2;
        if (s == ps) break;
        ps = s;
        if (smaller(s))
        {
            d = s-1;
        }
        else
        {
            l = s;
        }
    }
    if (smaller(d)) return l;
    else return d;
}