#include using namespace std; int n, k; vector a, dp, dp2; int dfs(int cur){ if(dp2[cur] != -1)return dp2[cur]; dp2[cur] = dp[cur]; for(int i = 0, d = 1; i < k; i++, d *= 5){ if(cur / d % 5 < 4 && dfs(cur + d)){ dp2[cur] = 1; dp[cur] = 0; } } return dp2[cur]; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> n >> k; a.resize(n, 0); dp.resize(25 * 25 * 25 * 25); dp2.resize(25 * 25 * 25 * 25, -1); for(int i = 0; i < n; i++){ string s; cin >> s; a[i] = stoi(s, nullptr, 5); dp[a[i]] = 1; } dfs(0); cout << n - accumulate(dp.begin(), dp.end(), 0) << endl; }