def f(a, b, c)
  ax = ax(c) - ax(a) - ax(b)
  a.gsub!("X", "0")
  b.gsub!("X", "0")
  c.gsub!("X", "0")
  n = (a.to_i + b.to_i) - c.to_i
  if n % ax == 0
    return n / ax
  else
    return "NA"
  end
end

def ax(string)
  result = 0
  string.each_char do |c|
    result *= 10
    if c == "X"
      result += 1
    end
  end
  return result
end
def main(input = STDIN)
  while !input.eof
    puts f(*input.gets.chomp.split(/[^\dX]/))
  end
end
main