#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll M = 1; M <= 10000000; M++){
        if(2*N - M*M + M > 0 && (2*N - M*M + M)%(2*M) == 0){
            ans++;
        }
    }
    cout << ans*2;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Pr pair<ll,ll>
#define Tp tuple<int,int,int>
using Graph = vector<vector<int>>;

int main(){
    string S[3];
    unordered_map<char,int> lab; int k = 0;
    rep(i,3){
        cin >> S[i];
        rep(j,S[i].size()){
            char c = S[i][j];
            if(!lab.count(c)){
                lab[c] = k; k++;
            }
        }
    }
    if(lab.size()>10){
        cout << "UNSOLVABLE" << endl; return 0;
    }
    int a = lab.size(); vector<ll> per;
    rep(i,10){
        per.push_back((ll)i);
    }
    do{
        ll s[3];
        rep(i,3){
            s[i] = 0; ll base = 1; int l = S[i].size();
            //if(i==2) cout << s[2] << endl;
            rep(j,l){
                s[i] += base*(per[lab[S[i][l-1-j]]]); base *= 10;
                //if(i==2) cout << lab[S[i][l-1-j]] << endl;
            }
        }
        //cout << s[2] << endl;
        /*if(per[0]==9&&per[1]==5&&per[2]==6&&per[3]==7&&
        per[4]==1&&per[5]==0&&per[6]==8&&per[7]==2){
            cout << s[0] << endl;
            cout << s[1] << endl;
            cout << s[2] << endl;
        }*/
        if(s[0]+s[1]==s[2]){
            bool ch = true;
            rep(i,3){
                if(per[lab[S[i][0]]]==0) ch = false;
            }
            if(ch){
                rep(i,3){
                    cout << s[i] << endl;
                }
                return 0;
            }
        }
    }while(next_permutation(per.begin(),per.end()));
    cout << "UNSOLVABLE" << endl;
}