while formula = STDIN.gets
  (0..9). each do |i|
    f = formula.gsub(/X/, i.to_s)
    l, r, a = f.chomp.split(/[+|=]/)
    if i == 0 and (l.length > 1 and l[0] == '0') or (r.length > 1 and r[0] == '0') or (a.length > 1 and a[0] == '0') then next end
    if l.to_i + r.to_i == a.to_i then
      puts i
      break
    end
    if i == 9 then
      puts 'NA'
    end
  end
end