#include <bits/stdc++.h>
using namespace std;
char c;
int mark[25];
int main() {
  int n, cnt = 0, point = 30;
  string s;
  cin >> n >> s;
  while (--n) {
    for (int i = 0; i < s.size(); i++) {
      cin >> c;
      if (c == s[i] && mark[i] == 0 && i < point) {
        cnt++;
        mark[i] = 1;
      } else if (c != s[i] && mark[i] != -1) {
        if (mark[i]) cnt--;
        point = min(point, i);
        mark[i] = -1;
      }
    }
  }
  cout << cnt;
  return 0;
}
