s = gets.chomp
n = gets.to_i

ans1 = eval(s)

a = s.split(/[+*]/).map(&:to_i)
op = s.chars.select {|c| c =~ /[+*]/ }
ans2 = a[0]
op.each_index do |i|
    if op[i] == '+'
        ans2 += a[i + 1]
    else
        ans2 *= a[i + 1]
    end
end

if [ans1, ans2] == [n, n]
    puts "U"
elsif ans1 == n
    puts "M"
elsif ans2 == n
    puts "L"
else
    puts "I"
end
