#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int isPalindrome(char s[]){
    int i=0; j=strlen(s)-1;
    while(i<j){
        if(s[i]!=s[j])
        i++;
        j--;
    }
    return 1;
}
int main{
    char num1[1001], num2[1001];
    scanf("%s", num1);
    scanf("%s", num2);
    
    if(isPalindrome(num1) && isPalindrome(num2)) {
        long long a = atoll(num1);
        long long b = atoll(num2);
        printf("%lld", a * b);
    } else {
        printf("Invalid input");
    }
    return 0;
    
}