#include std::vector pow5; int get(int S, int i) { return (S / pow5[i]) % 5; } int add(int S, int i) { return S + pow5[i]; } int main() { int n, k; std::cin >> n >> k; pow5.resize(k + 1, 1); for (int i = 1; i <= k; i++) pow5[i] = pow5[i - 1] * 5; std::vector v(pow5.back(), 0); for (int _ : std::ranges::iota_view(0, n)) { int x = 0; for (int _ : std::ranges::iota_view(0, k)) { char c; std::cin >> c; x = x * 5 + 4 - (c - '0'); } v[x] = 1; } auto w = v; for (int i = 0; i < k; i++) for (int S = 0; S < w.size(); S++) { if (get(S, i) == 4) continue; w[add(S, i)] += w[S]; } int res = 0; for (int S = 0; S < v.size(); S++) res += v[S] and (w[S] > v[S]); std::cout << res << '\n'; }