s = gets.chomp
n = gets.to_i
lr = 0
op = "+"
s.each_char do |c|
    if c == "+" || c == "*"
        op = c
    else
        if op == "+"
            lr += c.to_i
        else
            lr *= c.to_i
        end
    end
end
ma = eval(s)
if n == lr
    puts "L" if n != ma
    puts "U" if n == ma
else
    puts "I" if n != ma
    puts "M" if n == ma
end