while e = gets
    equation = e.chomp.sub!(/=/, '+').split('+')
    flag = false
    start_index = 0
    
    if (equation[0].length >= 2 && equation[0][0] == "X") ||
        (equation[1].length >= 2 && equation[1][0] == "X") ||
        (equation[2].length >= 2 && equation[2][0] == "X")
        start_index = 1
    end
    
    for i in start_index..9
        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

