def solve(str)
  left1, left2, right = str.match(/(.+)\+(.+)=(.+)/).to_a[1..-1]
  for i in "1".."9"
    l1, l2, r = left1.gsub("X", i), left2.gsub("X", i), right.gsub("X", i)
    if (l1.to_i + l2.to_i == r.to_i)
      return i
    end
  end
  l1, l2, r = left1.gsub("X", "0"), left2.gsub("X", "0"), right.gsub("X", "0")
  if (check(l1) and check(l2) and check(r) and (l1.to_i + l2.to_i == r.to_i))
    return 0
  else
    return "NA"
  end
end
def check(str)
  return (str.to_i.to_s == str)
end
while (str = gets)
  puts solve(str.chomp)
end