Language: C++

#include <iostream>
#include <string>
#include <sstream>
void replace(std::string& text,std::string bef,std::string aft){
  std::string::size_type pos = 0;
  while(pos = text.find(pos,bef)){
    if(pos!=std::string::npos)break;
    text.replace(pos,bef.length(),aft);
    pos += aft.length;
  }
  return ;
}

int main(){
  std::string s;
  while(std::cin>>s){
    if(std::cin.eof())return 0;
    int r = -1;
    for(int i=0;i<10;i++){
      std::string _s = s;
      std::stringstream ss;
      ss<<i;
      replace(_s,"X",ss.str());
      int a,b,c;
      char p,e;
      ss.str("");
      ss<<_s;
      ss>>a>>p>>b>>e>>c;
      if(a+b==c){
	r=i;break;
      }
    }
    if(r>=0)std::cout<<r<<std::endl;
    else{std::cout<<"NA"<<std::endl;}
  }
  return 0;
}

Compiler output:
a.cc: In function 'void replace(std::string&, std::string, std::string)':
a.cc:6:24: error: no matching function for call to 'std::__cxx11::basic_string<char>::find(std::__cxx11::basic_string<char>::size_type&, std::string&)'
    6 |   while(pos = text.find(pos,bef)){
      |               ~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:2740:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::find(const _CharT*, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2740 |       find(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
      |       ^~~~
/usr/include/c++/14/bits/basic_string.h:2740:41: note:   no known conversion for argument 2 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
 2740 |       find(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
      |                               ~~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:2720:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, typename __gnu_cxx::__alloc_traits<typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other>::size_type> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::find(const _Tp&, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2720 |         find(const _Tp& __svt, size_type __pos = 0) const
      |         ^~~~
/usr/include/c++/14/bits/basic_string.h:2720:9: note:   template argument deduction/substitution failed:
a.cc:6:29: note:   cannot convert 'bef' (type 'std::string' {aka 'std::__cxx11::basic_string<char>'}) to type 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
    6 |   while(pos = text.find(pos,bef)){
      |                             ^~~
/usr/include/c++/14/bits/basic_string.h:2691:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::find(const _CharT*, size_type, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2691 |       find(const _CharT* __s, size_type __pos, size_type __n) const
      |       ^~~~
/usr/include/c++/14/bits/basic_string.h:2691:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2706:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::find(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2706 |       find(const basic_string& __str, size_type __pos = 0) const
      |       ^~~~
/usr/include/c++/14/bits/basic_string.h:2706:32: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} to 'const std::__cxx11::basic_string<char>&'
 2706 |       find(const basic_string& __str, size_type __pos = 0) const
      |            ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:2758:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::find(_CharT, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2758 |       find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
      |       ^~~~
/usr/include/c++/14/bits/basic_string.h:2758:34: note:   no known conversion for argument 2 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
 2758 |       find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
      |                        ~~~~~~~~~~^~~~~~~~~
a.cc:9:16: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
    9 |     pos += aft.length;
      |            ~~~~^~~~~~
      |                      ()