#include<bits/stdc++.h> using namespace std; int main(){ unsigned int a,b; cin>>a>>b; unsigned long long c= (int)pow(a,b)%1000; printf("%03lld",c); }