#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N;
	long long int ans = 0;
	vector<long long int>s(19);
	vector<long long int>f(19);
	for (int i = 0; i <= 9; i++) {
		s[i + 9] ++;
		for (int j = 1; j <= 9; j++) {
			f[i - j + 9]++;
			s[i - j + 9]++;
		}
	}
	long long int by = 1;
	while (N % 10 == 0) {
		N /= 10;
		by *= 10;
	}
	by--;
	for (long long int i = 1; i <= 9; i++) {
		if (i * 9 == N) {
			if (by) {
				ans += s[i + 9];
			}
			else {
				ans += f[i + 9];
			}
		}
		if (i * 99 == N) {
			if (by) {
				ans += s[i + 9] * 10;
			}
			else {
				ans += f[i + 9] * 10;
			}
		}
		for (long long int j = -9; j <= 9; j++) {
			if (i * 999 + j * 90 == N) {
				if (by) {
					ans += s[i + 9] * s[j + 9];
				}
				else {
					ans += f[i + 9] * s[j + 9];
				}
			}
			if (i * 9999 + j * 990 == N) {
				if (by) {
					ans += s[i + 9] * s[j + 9] * 10;
				}
				else {
					ans += f[i + 9] * s[j + 9] * 10;
				}
			}
			for (long long int k = -9; k <= 9; k++) {
				if (i * 99999 + j * 9990 + k * 900 == N) {
					if (by){
						ans += s[i + 9] * s[j + 9] * s[k + 9];
					}
					else {
						ans += f[i + 9] * s[j + 9] * s[k + 9];
					}
				}
				if (i * 999999 + j * 99990 + k * 9900 == N) {
					if (by) {
						ans += s[i + 9] * s[j + 9] * s[k + 9] * 10;
					}
					else {
						ans += f[i + 9] * s[j + 9] * s[k + 9] * 10;
					}
				}
				for (long long int l = -9; l <= 9; l++) {
					if (i * 9999999 + j * 999990 + k * 99900 + l * 9000 == N) {
						if (by) {
							ans += s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9];
						}
						else {
							ans += f[i + 9] * s[j + 9] * s[k + 9] * s[l + 9];
						}
					}
					if (i * 99999999 + j * 9999990 + k * 999900 + l * 99000 == N) {
						if (by) {
							ans += s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * 10;
						}
						else {
							ans += f[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * 10;
						}
					}
					for (long long int m = -9; m <= 9; m++) {
						if (i * 999999999 + j * 99999990 + k * 9999900 + l * 999000 + m * 90000 == N) {
							if (by) {
								ans += s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9];
							}
							else {
								ans += f[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9];
							}
						}
						if (i * 9999999999 + j * 999999990 + k * 99999900 + l * 9999000 + m * 990000 == N) {
							if (by) {
								ans += s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * 10;
							}
							else {
								ans += f[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * 10;
							}
						}
						for (long long int n = -9; n <= 9; n++) {
							if (i * 99999999999 + j * 9999999990 + k * 999999900 + l * 99999000 + m * 9990000 + n * 900000 == N) {
								if (by) {
									ans += s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9];
								}
								else {
									ans += f[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9];
								}
							}
							if (i * 999999999999 + j * 99999999990 + k * 9999999900 + l * 999999000 + m * 99990000 + n * 9900000 == N) {
								if (by) {
									ans += s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9] * 10;
								}
								else {
									ans += f[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9] * 10;
								}
							}
							for (long long int o = -9; o <= 9; o++) {
								if (i * 9999999999999 + j * 999999999990 + k * 99999999900 + l * 9999999000 + m * 999990000 + n * 99900000 + o * 9000000 == N) {
									if (by) {
										ans += s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9] * s[o + 9];
									}
									else {
										ans += f[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9] * s[o + 9];
									}
								}
								if (i * 99999999999999 + j * 9999999999990 + k * 999999999900 + l * 99999999000 + m * 9999990000 + n * 999900000 + o * 99000000 == N) {
									if (by) {
										ans += s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9] * s[o + 9] * 10;
									}
									else {
										ans += f[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9] * s[o + 9] * 10;
									}
								}
								if (999999999999999 + i * 99999999999990 + j * 9999999999900 + k * 999999999000 + l * 99999990000 + m * 9999900000 + n * 999000000 + o * 90000000 == N) {
									if (by) {
										ans += s[1 + 9] * s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9] * s[o + 9];
									}
									else {
										ans += f[1 + 9] * s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9] * s[o + 9];
									}
								}
								if (i * 99999999999990 + j * 9999999999900 + k * 999999999000 + l * 99999990000 + m * 9999900000 + n * 999000000 + o * 90000000 == N) {
									if (by) {
										ans += s[0 + 9] * s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9] * s[o + 9];
									}
									else {
										ans += f[0 + 9] * s[i + 9] * s[j + 9] * s[k + 9] * s[l + 9] * s[m + 9] * s[n + 9] * s[o + 9];
									}
								}
							}
						}
					}
				}
			}
		}
	}
	by++;
	if (by > 1) {
		by *= 9;
		by /= 10;
	}
	cout << ans * by << endl;
	return 0;
}


Measured memory_bytes: 256