#include<iostream>
using namespace std;
long long n;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.sync_with_stdio(false);
    long long a,b,prob,br1=0,br12,izv=1,br3=0,m,br=2,sum=0;
    cin>>n>>a>>b;
    while(br<=n){
            if(br>=3){

            a=b;
            b=prob%1000;

        }
        prob=a*b;
        m=prob;
        if(m%10!=0){
            prob-=1;
        }else{

            prob+=9;
        }
        m/=10;
        if(m%10!=0){
            prob-=10;
        }else{

            prob+=90;
        }
        m/=10;
        if(m%10!=0){
            prob-=100;
        }else{

            prob+=900;
        }
        br++;
    }

    cout<<b;
    return 0;
}
