#include <iostream>
#include <array>
unsigned int fib_mod(unsigned int n, unsigned int m) {using M = std::array<unsigned int, 3>;
auto mul = [m] (M & me, const M & other) {
me[2] = ((me[1] * other[1]) % m + (me[2] * other[2]) % m) % m;
unsigned int me_1 = me[1];
me[1] = ((me[0] * other[1]) % m + (me[1] * other[2]) % m) % m;
me[0] = ((me[0] * other[0]) % m + (me_1 * other[1]) % m) % m;
};
M r{{1, 1, 0}}, e{{1, 0, 1}}, ans{e};
while (n) {
if (n & 1) {
mul(ans, r);
}
mul(r, M(r));
n /= 2;
}
return ans[1];
}
int main() {
std::cout << fib_mod(1<<31, 1<<31) << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YXJyYXk+Cgp1bnNpZ25lZCBpbnQgZmliX21vZCh1bnNpZ25lZCBpbnQgbiwgdW5zaWduZWQgaW50IG0pIHt1c2luZyBNID0gc3RkOjphcnJheTx1bnNpZ25lZCBpbnQsIDM+OwogICAgYXV0byBtdWwgPSBbbV0gKE0gJiBtZSwgY29uc3QgTSAmIG90aGVyKSB7CiAgICAgICAgbWVbMl0gPSAoKG1lWzFdICogb3RoZXJbMV0pICUgbSArIChtZVsyXSAqIG90aGVyWzJdKSAlIG0pICUgbTsKICAgICAgICB1bnNpZ25lZCBpbnQgbWVfMSA9IG1lWzFdOwogICAgICAgIG1lWzFdID0gKChtZVswXSAqIG90aGVyWzFdKSAlIG0gKyAobWVbMV0gKiBvdGhlclsyXSkgJSBtKSAlIG07CiAgICAgICAgbWVbMF0gPSAoKG1lWzBdICogb3RoZXJbMF0pICUgbSArIChtZV8xICogb3RoZXJbMV0pICUgbSkgJSBtOwogICAgfTsKICAgIE0gcnt7MSwgMSwgMH19LCBle3sxLCAwLCAxfX0sIGFuc3tlfTsKICAgIHdoaWxlIChuKSB7CiAgICAgICAgaWYgKG4gJiAxKSB7CiAgICAgICAgICAgIG11bChhbnMsIHIpOwogICAgICAgIH0KICAgICAgICBtdWwociwgTShyKSk7CiAgICAgICAgbiAvPSAyOwogICAgfQogICAgcmV0dXJuIGFuc1sxXTsKfQoKaW50IG1haW4oKSB7CiAgICBzdGQ6OmNvdXQgPDwgZmliX21vZCgxPDwzMSwgMTw8MzEpIDw8IHN0ZDo6ZW5kbDsKICAgIHJldHVybiAwOwp9