#ifndef __SETS_H__
#define __SETS_H__

/* updated: 2020-03-28 */

// 集合系の関数などを置きたい

#include <cstdint>
#include <vector>
#include <cassert>

#ifdef _MSC_VER
#include <intrin.h>
#endif

// ビット演算系

/* 立っているビットの数を数える */
inline int popcount(uint64_t value) {
#ifdef _MSC_VER
	return __popcnt64(value);
#elif defined(__GNUC__)
	return __builtin_popcountll(value);
#else
	value = (value & 0x5555555555555555) + ((value >>  1) & 0x5555555555555555);
	value = (value & 0x3333333333333333) + ((value >>  2) & 0x3333333333333333);
	value = (value & 0x0f0f0f0f0f0f0f0f) + ((value >>  4) & 0x0f0f0f0f0f0f0f0f);
	value = (value & 0x00ff00ff00ff00ff) + ((value >>  8) & 0x00ff00ff00ff00ff);
	value = (value & 0x0000ffff0000ffff) + ((value >> 16) & 0x0000ffff0000ffff);
	value = (value & 0x00000000ffffffff) + ((value >> 32) & 0x00000000ffffffff);
	return value;
#endif
}

/* 最上位ビットの位置を返す (0-based, value == 0 のときは -1 を返す) */
/* floor(log2(value)) と一致する */
inline int msbPosition(uint64_t value) {
	value |= value >> 1;
	value |= value >> 2;
	value |= value >> 4;
	value |= value >> 8;
	value |= value >> 16;
	value |= value >> 32;
	return popcount(value) - 1;
}

/* 最下位ビットの位置を返す (0-based, value == 0 のときは 64 を返す) */
inline int lsbPosition(uint64_t value) {
	value |= value << 1;
	value |= value << 2;
	value |= value << 4;
	value |= value << 8;
	value |= value << 16;
	value |= value << 32;
	return 64 - popcount(value);
}

/* 最上位ビットを取得 (value == 0 のときは 0 を返す) */
inline uint64_t msb(uint64_t value) {
	if (value == 0) return uint64_t();
	return uint64_t(1) << msbPosition(value);
}

/* 最下位ビットを取得 (value == 0 のときは 0 を返す) */
/* TODO: これに関しては明らかに value & -value のほうが速いと思うけどどうしようか */
inline uint64_t lsb(uint64_t value) {
	if (value == 0) return uint64_t();
	return uint64_t(1) << lsbPosition(value);
}

/* ceil(log2(value)) を返す (value == 0 のときは -1 を返す) */
/* 戻り値の範囲は -1 <= ret <= 64 */
inline int ceilLog2(uint64_t value) {
	if (value == 0) return -1;
	return msbPosition(value - 1) + 1;
}

/* ビットの並びを逆転させる */
inline uint64_t bitReverse(uint64_t val) {
	val = (val & 0x5555555555555555) <<  1 | (val & 0xAAAAAAAAAAAAAAAA) >>  1;
	val = (val & 0x3333333333333333) <<  2 | (val & 0xCCCCCCCCCCCCCCCC) >>  2;
	val = (val & 0x0F0F0F0F0F0F0F0F) <<  4 | (val & 0xF0F0F0F0F0F0F0F0) >>  4;
	val = (val & 0x00FF00FF00FF00FF) <<  8 | (val & 0xFF00FF00FF00FF00) >>  8;
	val = (val & 0x0000FFFF0000FFFF) << 16 | (val & 0xFFFF0000FFFF0000) >> 16;
	val = (val & 0x00000000FFFFFFFF) << 32 | (val & 0xFFFFFFFF00000000) >> 32;
	return val;
}

/* 下位 digits ビットについてビットの並びを逆転させる (上位ビットは無視) */
inline uint64_t bitReverse(uint64_t val, int digits) {
	assert(digits > 0 || digits <= 64);
	return bitReverse(val) >> (64 - digits);
}

/* 1 << quantity を返す */
inline uint64_t shift(int quantity) {
	return uint64_t(1) << quantity;
}

/* 整数 sets を集合としてみたとき、element 番目の要素を持つかどうか bool(s & (1 << element)) */
inline bool has(uint64_t sets, int element) {
	return sets & shift(element);
}

template <class T>
void bitReverseArray(std::vector<T>& arr);

/* 配列の要素を添字のビット逆順に並べ替える (配列長は2冪) */
template <class T>
void bitReverseArray(std::vector<T>& arr) {
	const int rank = msbPosition(arr.size());
	const int length = 1 << rank;
	assert(arr.size() == length);

	for (int i = 0; i < length; ++i) {
		int j = bitReverse(i, rank);
		if (j > i) {
			std::swap(arr[i], arr[j]);
		}
	}
}


// 畳み込み演算系

template <class T>
void transformSubsetZeta(std::vector<T>& arr);
template <class T>
void transformInverseSubsetZeta(std::vector<T>& arr);
template <class T>
void transformSupersetZeta(std::vector<T>& arr);
template <class T>
void transformInverseSupersetZeta(std::vector<T>& arr);
template <class T>
void transformHadamard(std::vector<T>& vec);
template <class T>
std::vector<T> convolveOnXor(const std::vector<T>& a, const std::vector<T>& b);

/* 逆変換とまとめられないか？ */
/* 高速ゼータ変換 O(n log n), n は2冪 */
/* b[s] = sum[t is a subset of s] a[t] */
template <class T>
void transformSubsetZeta(std::vector<T>& arr) {
	const uint64_t length = arr.size();
	const int level = msbPosition(length);
	assert(length == shift(level));

	for (int k = 0; k < level; ++k) {
		for (uint64_t s = 0; s < length; ++s) {
			if (has(s, k)) continue;
			arr[s] += arr[s | shift(k)];
		}
	}
}

/* 高速ゼータ変換の逆変換 O(n log n), n は2冪 */
template <class T>
void transformInverseSubsetZeta(std::vector<T>& arr) {
	const uint64_t length = arr.size();
	const int level = msbPosition(length);
	assert(length == (uint64_t(1) << level));

	for (int k = 0; k < level; ++k) {
		for (uint64_t s = 0; s < length; ++s) {
			if (has(s, k)) continue;
			arr[s | shift(k)] -= arr[s];
		}
	}
}

/* 高速(上位集合)ゼータ変換 O(n log n), n は2冪 */
/* b[s] = sum[t is a superset of s] a[t] */
template <class T>
void transformSupersetZeta(std::vector<T>& arr) {
	const uint64_t length = arr.size();
	const int level = msbPosition(length);
	assert(length == (uint64_t(1) << level));

	for (int k = 0; k < level; ++k) {
		for (uint64_t s = 0; s < length; ++s) {
			if (has(s, k)) continue;
			arr[s | shift(k)] += arr[s];
		}
	}
}

/* 高速(上位集合)ゼータ変換の逆変換 O(n log n), n は2冪 */
template <class T>
void transformInverseSupersetZeta(std::vector<T>& arr) {
	const uint64_t length = arr.size();
	const int level = msbPosition(length);
	assert(length == (uint64_t(1) << level));

	for (int k = 0; k < level; ++k) {
		for (uint64_t s = 0; s < length; ++s) {
			if (has(s, k)) continue;
			arr[s] -= arr[s | shift(k)];
		}
	}
}

/* 高速アダマール変換 O(n log n), n は2冪 (オーバーフロー注意) */
/* オーバーフロー注意 */
template <class T>
void transformHadamard(std::vector<T>& vec) {
	const int rank = msbPosition(vec.size());
	const int length = 1 << rank;
	assert(vec.size() == length);

	/* バタフライ演算 */
	auto butterfly = [](T& a, T& b) -> void {
		T tmp(a);
		a += b;
		b = tmp - b;
	};

	/* FFT 同様に各ビットについてバタフライ演算を回す */
	for (int cnt = 0; cnt < rank; ++cnt) {
		const int blk_max = length >> (cnt + 1);
		const int blk_size = 1 << (cnt + 1);

		for (int blk = 0; blk < blk_max; ++blk) {
			const int idx_max = 1 << cnt;

			for (int idx = 0; idx < idx_max; ++idx) {
				const int left = (blk * blk_size + idx);
				const int right = left + blk_size / 2;

				butterfly(vec[left], vec[right]);
			}
		}
	}
}

/* xor 畳み込み O(n log n), n は2冪 (オーバーフロー注意) */
/* ret[n] = sum [i xor j == n] (a[i] * b[j]) */
template <class T>
std::vector<T> convolveOnXor(const std::vector<T>& a, const std::vector<T>& b) {
	const int rank = msbPosition(a.size());
	const int size = 1 << rank;
	assert(a.size() == b.size());
	assert(a.size() == size);

	std::vector<T> a_copied = a;
	std::vector<T> b_copied = b;
	transformHadamard(a_copied);
	transformHadamard(b_copied);

	std::vector<T> ret(size);
	for (int i = 0; i < size; ++i) {
		ret[i] = a_copied[i] * b_copied[i];
	}
	transformHadamard(ret);

	/* 関数 transformHadamard はユニタリ変換ではないので係数を調整 */
	/* IntMod など -> 逆元を前計算することも可能 */
	for (int i = 0; i < size; ++i) {
		ret[i] /= size;
	}
	return ret;
}



#endif


#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>

using namespace std;
using uint = uint32_t;
using LL = int64_t;
using ULL = uint64_t;
using PP = pair<LL, LL>;
template <typename T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#define REP(i, a, n) for(LL i = (a), i##_max_ = (n); i < i##_max_; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##_min_ = (a); i >= i##_min_; --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP { cin.tie(NULL); ios::sync_with_stdio(false); }
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U> ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template <class T> T Next() { T buf; cin >> buf; return buf; }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }

#ifdef ONLY_MY_ENVIR
#include "Accumulator.h"
#include "Algebraic.h"
#include "BinaryMatrix.h"
#include "BinaryTree.h"
#include "Bipartite.h"
#include "BIT.h"
#include "Compressor.h"
#include "Decompositions.h"
#include "DiscreteLog.h"
#include "DynamicMod.h"
#include "Exponential.h"
#include "Factorization.h"
#include "FFT.h"
#include "FlowSolver.h"
#include "Geometric2D.h"
#include "Geometric2DFloat.h"
#include "Geometric3D.h"
#include "Geometric3DFloat.h"
#include "Graph.h"
#include "GraphUtil.h"
#include "Interpolation.h"
#include "IntMod.h"
#include "KDTree.h"
#include "LazySegmentTree.h"
#include "LIS.h"
#include "Math.h"
#include "MathUtil.h"
#include "Matrix.h"
#include "MinCostFlowSolver.h"
#include "MinMax.h"
#include "Numbers.h"
#include "Optimize.h"
#include "Permutation.h"
#include "Polynomial.h"
#include "Position.h"
#include "Random.h"
#include "Range.h"
#include "Rational.h"
#include "RuntimeMod.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "Sets.h"
#include "Shortest.h"
#include "SlidingWindow.h"
#include "SpanningTree.h"
#include "StringSearching.h"
#include "SuffixArray.h"
#include "SwitchList.h"
#include "Timer.h"
#include "Tree.h"
#include "TreeUtil.h"
#include "UnionFind.h"
#include "Util.h"
#include "VectorUtil.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>>(istream& ist, __int128& val) { LL tmp; ist >> tmp; val = tmp; return ist; }
ostream& operator<<(ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

string v;
LL cat(int n, int s) {
	LL sum = 1;
	REP(i, 0, (n + 1) / 2) {
		int j = n - 1 - i;
		int cnt = 0;
		REP(a, 0, 10) {
			REP(b, 0, 10) {
				if (i == 0 && a == 0) continue;
				if (i == 0 && b == 0) continue;
				int di = a - b - (i > 0 && has(s, i - 1));
				int dj = b - a - (j > 0 && has(s, j - 1));
				if (di < 0) di += 10;
				if (dj < 0) dj += 10;
				if (di != v[i] - '0') continue;
				if (dj != v[j] - '0') continue;
				bool ci = a < b || a == b && i > 0 && has(s, i - 1);
				bool cj = b < a || b == a && j > 0 && has(s, j - 1);
				if (ci != has(s, i)) continue;
				if (cj != has(s, j)) continue;
				++cnt;
			}
		}
		if (cnt == 0) return 0;
		sum *= cnt;
	}
	return sum;
}

LL sub(int n) {
	LL sum = 0;
	REP(s, 0, 1 << (n - 1)) {
		sum += cat(n, s);
	}
	return sum;
}

int main() {
	cin >> v;
	int dig = v.size();
	reverse(v.begin(), v.end());
	v += string(18, '0');
	
	LL sum = 0;
	REP(n, dig, 19) {
		sum += sub(n);
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3624