$<.each do |s|
  s.chomp!
  puts 10.times.find {|x|
    ns = s.tr('X', x.to_s).scan(/\d+/)
    next false if ns.any? {|n| n.size >= 2 && n[0] == ?0 }
    a, b, c = ns.map(&:to_i)
    a + b == c
  } || 'NA'
end