#include <bits/stdc++.h>
using namespace std;
int main()
{
int a, b, ans;
cin >> a >> b;
ans = 1;
for (int i = 1; i <= b; i++)
ans = (ans * a) % 1000;
if (ans < 10)
cout << "00" << ans;
else if (ans < 100)
cout << "0" << ans;
else
cout << ans;
return 0;
}