Example

Input

1+2*3+4
11


Output

M
s = input()
l = len(s)
def parse1(s):
    cur = 0
    num = 0; res = 0; op = '+'
    while cur < len(s):
        if s[cur] in '+*':
            if op is '+':
                res += num
            else:
                res *= num
            num = 0; op = s[cur]
        else:
            num = 10 * num + int(s[cur])
        cur += 1
    if op is '+':
        res += num
    else:
        res *= num
    return res
def parse2(s):
    cur = 0
    def number():
        nonlocal cur
        v = int(s[cur]); cur += 1
        return v
    def term():
        nonlocal cur
        res = 1
        while 1:
            res *= number()
            if l <= cur or s[cur] != '*':
                break
            cur += 1
        return res
    def expr():
        nonlocal cur
        res = 0
        while 1:
            res += term()
            if l <= cur or s[cur] != '+':
                break
            cur += 1 # '+'
        return res
    return expr()
v = int(input())
r1 = parse1(s) == v
r2 = parse2(s) == v
print("ILMU"[r1+2*r2])