while e = gets
    equation = e.chomp.sub!(/=/, '+').split('+')
    flag = false
    
    for i in 0..9
        sec1, sec2, sec3 = "", "", ""
        sec1 = equation[0].gsub("X", i.to_s)
        sec2 = equation[1].gsub("X", i.to_s)
        sec3 = equation[2].gsub("X", i.to_s)
        
       
        if sec1.to_i + sec2.to_i == sec3.to_i
            puts i
            flag = true
            break
        end
    end
    puts "NA" if flag == false
end
