#include <bits/stdc++.h>
using namespace std;

int findCurrentNumber(int previous, int previousAfter)
{
    if(previous==0 || previousAfter==0)
    {
        return 9;
    }

    int digits=(previous*previousAfter)%1000;
    int currentNumber=0;
    int ten=1;

    if(previous*previousAfter>=100 && digits<100)
    {
        currentNumber=900;
    }

    while(digits!=0)
    {
        int currentDigits=digits%10;

        if(currentDigits==0)
        {
            currentDigits=9;
        }
        else
        {
            currentDigits--;
        }

        currentNumber+=ten*currentDigits;
        ten*=10;
        digits/=10;
    }

    return currentNumber;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    long long numberFind;
    int numberOne, numberTwo;
    cin >> numberFind >> numberOne >> numberTwo;

    int currentNumber;
    int previous=numberTwo, previousAfter=numberOne;

    for(int current=3; current<=numberFind; current++)
    {
        currentNumber=findCurrentNumber(previous, previousAfter);
        previousAfter=previous;
        previous=currentNumber;
    }

    cout << currentNumber;
    return 0;
}

