#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
int d[30]; 
ll f[30][2][2];

int main() {
	int D; 
	cin>>D; 
	memset(d, 0, sizeof(d)); 
	int i = 0; 
	while (D>0) {
		d[i] = D % 10; 
		D /= 10; 
		i++; 
	}
	ll ans = 0; 
	for (int len = i-1; len <= 20; ++len) {
		memset(f,0,sizeof(f)); 
		f[0][0][0] = 1; 
		for (int i = 0; i<=len/2; i++) {
			for (int l0 = 0; l0 <= 1; ++l0) 
			for (int r0 = 0; r0 <= 1; ++r0) 
			for (int l1 = 0; l1 <= 1; ++l1) 
			for (int r1 = 0; r1 <= 1; ++r1) 
				for (int x = 0+(i==0); x <= 9; ++x) 
					for (int y = 0; y <= 9; ++y) 
						if (x+d[len-i]+l1==l0*10+y && y+d[i]+r0==r1*10+x) {
							f[i+1][l1][r1] += f[i][l0][r0]; 
							if (i==len/2) {
								if (len % 2 == 0) {
									if (l1==r0 && l0==r1 && x==y) ans += f[i][l0][r0]; 
								}
								else {
									if (l1 == r1) ans += f[i][l0][r0]; 
								}
							}
						}
		}
	}
	cout<<ans<<endl; 
}

#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
double val;
long long a,res;
int two,five;
map<pair<int,int>,int> cnt;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>val;
		a=llround(val*1e9);
		two=five=0;
		while(a%2==0){
			two++;
			a/=2;
		}
		while(a%5==0){
			five++;
			a/=5;
		}
		cnt[make_pair(two,five)]++;
	}
	for(auto p1:cnt){
		for(auto p2:cnt){
			if((p1.first.first+p2.first.first)>=18&&(p1.first.second+p2.first.second)>=18){
				if(p1==p2) res+=(long long)(p1.second)*(long long)(p1.second-1);
				else res+=(long long)(p1.second)*(long long)(p2.second);
			}
		}
	}
	cout<<res/2LL<<endl;
	return 0;
}
