#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
using namespace std;

int32_t main() {
	int start = clock();
	int p = 8624;
	cpp_int M;
	bit_set(M, p);
	M = M-1; // M = 2^p - 1;
	cpp_int S;
	S = 4;
	while(p>2) {
	         S = pow(S, 2);
	         S -= 2;
	
	         S %= M;
	         p--;         
	}
	// cout << S << endl;
	int end = clock();
	cout << "time: " << (end - start)/(double)(CLOCKS_PER_SEC)*1000 << " milliseconds\n";

}