#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

string str;
int now, cnt;

int toInt(){
  int num = 0;
  for(int i = now ; ; i++){
    if(str[i] == '+' || str[i] == '=') break;
    num *= 10;
    if(str[i] == 'X') num += cnt;
    else num += str[i]-'0';
    now++;
  }
  now++;
  return num;
}

int main(){
  while(cin >> str){
    str += "==";
    int ans = 100;
    cnt = 0;
    while(1){
      if(cnt == 10) break;
      int left1 = toInt();
      int left2 = toInt();
      int right = toInt();
      cnt++;
      now = 0;
      
      if(left1 + left2 == right){
	ans = cnt-1;
	break;
      }
    }
    
    if(ans == 100) cout << "NA" << endl;
    else cout << ans << endl;
  }
  return 0;
}

      