#include <bits/stdc++.h>
using namespace std;
#define go(x, d) while (x % d == 0) x /= d;
int main() {
ifstream cin("dtcsu.in");
ofstream cout("dtcsu.out");
char bla[16]; for (int i = 0; i < 276997; ++i) cin >> bla;
int q; cin >> q;
int tot = 0;
while (q > 4) {
long long x, y, z, t; cin >> x >> y >> z >> t;
go(x, 128); go(y, 128); go(z, 128); go(t, 128);
go(x, 2); go(y, 2); go(z, 2); go(t, 2);
go(x, 243); go(y, 243); go(z, 243); go(t, 243);
go(x, 3); go(y, 3); go(z, 3); go(t, 3);
go(x, 625); go(y, 625); go(z, 625); go(t, 625);
go(x, 5); go(y, 5); go(z, 5); go(t, 5);
go(x, 2401); go(y, 2401); go(z, 2401); go(t, 2401);
go(x, 7); go(y, 7); go(z, 7); go(t, 7);
go(x, 1331); go(y, 1331); go(z, 1331); go(t, 1331);
go(x, 11); go(y, 11); go(z, 11); go(t, 11);
tot += (x == 1) + (y == 1) + (z == 1) + (t == 1);
q -= 4;
}
while (q--) {
long long x; cin >> x;
go(x, 2); go(x, 3); go(x, 5); go(x, 7); go(x, 11);
tot += (x == 1);
}
cout << tot << '\n';
return 0;
}