• + 0 comments

    include

    using namespace std;

    long strangeCounter(long t) { long cycle_start = 1; long cycle_length = 3;

    while (cycle_start + cycle_length <= t) {
        cycle_start += cycle_length;
        cycle_length *= 2;
    }
    
    return cycle_length - (t - cycle_start);
    

    }

    int main() { ios::sync_with_stdio(false); cin.tie(NULL);

    long t; cin >> t;
    cout << strangeCounter(t) << "\n";
    
    return 0;
    

    }