#include using namespace std; int ID(int a = 0, int b = 0, int c = 0, int d = 0, int e = 0, int f = 0, int g = 0, int h = 0) { return (a + 5 * (b + 5 * (c + 5 * (d + 5 * (e + 5 * (f + 5 * (g + 5 * h))))))); } int ID(array arr) { return ID(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7]); } const int sss = 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5; inline int nxx(int id, int a) { int x = 1; for (int i = 0; i < a; i ++) { x *= 5; } id += x; return id; } int main () { int N, K; cin >> N >> K; int num[sss]; for (int& a : num) { a = 0; } int A[200020]; for (int i = 0; i < N; i ++) { int id = 0; A[i] = 0; string s; int bb = 1; cin >> s; for (auto a : s) { a -= '0'; id += a * bb; bb *= 5; } num[id] ++; A[i] = id; } for (int p = 0; p < 8; p ++) { for (int i = sss - 1; i >= 0; i --) { int nx = nxx(i, p); if (nx < sss) { num[i] += num[nx]; } } } int ans = 0; for (auto& a : A) { ans += (num[a] > 1); } cout << ans << endl; }