#include<iostream>
using namespace std;
int main()
{
int x,y;
int i=0;
char str[2];
cout<<"Input x and y(x**y):";
cin>>x>>str[1]>>str[2]>>y;
int last=1;
for(;i<y;i++)
{
last=last*x%1000;
}
cout<<"The last three digits of "<<x<<"**"<<y<<"is "<<last<<endl;
return 0;
}