$stdin.each do |s|
  n = nil
  (?0..?9).each do |x|
    res = s.gsub("X", x)
    a, b, c = res.split(/[^\d]/).map(&:to_i)
    if a + b == c && !res[/(\D|^)0/]
      n = x
      break
    end
  end
  if n
    puts n
  else
    puts "NA"
  end
end