#include <iostream>
#include <string>
using namespace std;

int main(){
	string s;
	while(cin >> s){
		bool flag = false,f = false;
		int x = 0,sum = 0,tmp = 0,xtmp = 0,pos;
		for(int i = 0;i < s.length();i++){
			if(s[i] == '+' || s[i] == '=') {
				sum += tmp;
				x += xtmp;
				tmp = 0;
				xtmp = 0;
				f = false;
			}
			else if(s[i] != 'X'){
				tmp = tmp * 10 + s[i] - '0';
				xtmp *= 10;
				f = true;
			}
			else{
				xtmp = xtmp * 10 + 1;
				tmp *= 10;
				if(!f) flag = true;
				f = true;
			}
		}
		int a = sum - tmp,b = xtmp - x;
		if(a % b) cout << "NA" << endl;
		else if(a / b < 0 || a / b >= 10) cout << "NA" << endl;
		else{
			int ans = a / b;
			if(ans == 0 && flag) cout << "NA" << endl;
			else cout << ans << endl;
		}
	}
	return 0;
}