#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#define mem(a) memset(a,0,sizeof(a))

using namespace std;

char str[30];
int ans;
int M,L;

int main()
{
	//freopen("in.txt","r",stdin);
	while(~scanf("%s",str))
	{
	    M = 0;L = 0;
	    scanf("%d",&ans);
	    char strr[30] = "";
	    strcat(strr,str);
	    int len = strlen(str);
	    if(len == 1)
	    {
	        L = M  = str[0]-48;
	        if(ans == M&&ans != L)cout<<"M"<<endl;
	    else if(ans == L && ans != M)cout<<"L"<<endl;
	    else if(ans == L && ans == M)cout<<"U"<<endl;
	    else cout<<"I"<<endl;
	        continue;
	    }
	    for(int i = 0;i < len;i ++)
	    {
	        if(str[i] == '+')
	        {
	            int a = str[i-1]-48;
	            int b = str[i+1]-48;
	            str[i+1] = (a + b) + 48;
	        }
	        else if(str[i] == '*')
	        {
	            int a = str[i-1]-48;
	            int b = str[i+1]-48;
	            str[i+1] = (a * b);
	        }
	        if(i == len - 1)L = str[i];
	    }
	    for(int i = 0;i < len;i ++)
	    {
	        if(strr[i] == '*')
	        {
	            M+=(strr[i-1]-'0')*(strr[i+1]-'0');
	            strr[i] = strr[i-1] = strr[i + 1] = '@';
	        }
	    }
	    for(int i = 0 ;i < len;i ++)
	    {
	        if(strr[i] == '+')
	        {
	            if(strr[i-1] >= '0'&&strr[i-1]<='9')M+=(strr[i-1]-48);
	            if(strr[i+1] >= '0'&&strr[i+1]<='9')M+=(strr[i+1]-48);
	        }
	        //if(i == len -1)M = str[i];
	    }
	    //cout<<L<<"  "<<M<<endl;
	    if(ans == M&&ans != L)cout<<"M"<<endl;
	    else if(ans == L && ans != M)cout<<"L"<<endl;
	    else if(ans == L && ans == M)cout<<"U"<<endl;
	    else cout<<"I"<<endl;
	}
	return 0;
}