### main

expr = gets.strip
bans = gets.to_i

mf = eval expr

lr = expr[0].to_i
k = 1
while k < expr.length
  if expr[k] == '+'
    lr += expr[k + 1].to_i
  else
    lr *= expr[k + 1].to_i
  end
  k += 2
end

idx = 0
idx |= 1 if bans == mf
idx |= 2 if bans == lr

puts ["I", "M", "L", "U"][idx]