def solve(str)
  left1, left2, right = str.match(/(.+)\+(.+)=(.+)/).to_a[1..-1]
  for i in "0".."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
  return "NA"
end
while (str = gets)
  puts solve(str.chomp)
end