1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include <math.h>

using namespace std;

int howManyDigits(int number){
    int howmany = 0;
    while(number >= 1){
        number/=10;
        howmany++;
    }
    return howmany;
}

string reverseString(string a){
    string result = "";
    for (int i = a.length() - 1; i >= 0; i--){
        result+=a[i];
    }
    return result;
}

int weirdAddition(int a, int b){
    string result = "";

    string stringA = reverseString(to_string(a));
    string stringB = reverseString(to_string(b));

    string longer = "";
    string shorter = "";

    if(stringA.length() > stringB.length()){
        longer = stringA;
        shorter = stringB;
    } else {
        longer = stringB;
        shorter = stringA;
    }

    for (int i = 0; i < longer.length(); i++){
        if(shorter.length() > i){
            int first = longer[i] - '0';
            int second = shorter[i] - '0';
            result+=reverseString(to_string(first + second));
        } else {
            result+=longer[i];
        }
    }
    
    return stoi(reverseString(result));
}

int main(){
    int number;
    cin >> number;

    int howmany = 0;

    for (int i = 0; i <= number; i++){
        for (int j = 0; j <= number; j++){
            if(weirdAddition(i,j) == number){
                howmany++;
            }
        }
    }

    cout << howmany;
    return 0;
}