import std.stdio, std.bigint, std.array;

void main()
{
    string a, b, l;
    loop:
    while(readf("%s+%s=%s\n", &a, &b, &l))
    {
        foreach(char c; '0' .. '9' + 1)
        {
            if(a.replace("X", [c]).BigInt + b.replace("X", [c]).BigInt == l.replace("X", [c]).BigInt)
            {
                c.writeln;
                continue loop;
            }
        }
        "NA".writeln;
    }
}