#include<stdio.h> int Mod(long long int n, long long int m) { long long int result = 1; for(long long int i = 0; i < n; ++i) { result = ( (result % m) * (2 % m) ) % m; } return result; } int main() { long long int n, m; printf("Enter power and divisor of 2: "); scanf("%lld%lld", &n, &m); printf("%lld\n", Mod(n, m)); return 0; }