#include <stdio.h>

int main()
{
    int x = 2014, y;
    for (y = 2014; y > 1; y /= 2) {
        x = x * x % 10000;
        if (y % 2) x = x * 2014 % 10000;
    }
    printf("%04d\n", x);

    return 0;
}
