#include <bits/stdc++.h>
using namespace std;
template <class T>
string change(T b) {
  string s;
  string Result;
  ostringstream convert;
  convert << b;
  Result = convert.str();
  return Result;
}
template <class T, class N>
T change1(N b, T s) {
  stringstream x1;
  x1 << b;
  x1 >> s;
  return s;
}
int index1(string s) {
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == ' ') return i;
  }
}
string ahmed(int n, string s) {
  string s1;
  for (int i = 0; i < n; i++) {
    s1 += s[i];
  }
  return s1;
}
string osama(int n, string s) {
  string s1;
  for (int i = n + 1; i < s.length(); i++) {
    s1 += s[i];
  }
  return s1;
}
template <class T>
int repeat(vector<T> v, T x) {
  int count = 0;
  for (int i = 0; i < v.size(); i++) {
    if (x == v[i]) count++;
  }
  return count;
}
int search2(vector<int> v, int s) {
  for (int i = 0; i < v.size(); i++) {
    if (s == v[i]) {
      return i;
    }
  }
  return -1;
}
int search1(string s, char c) {
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (c == s[i]) {
      count++;
    }
  }
  return count;
}
bool minimum(vector<int> v, int m) {
  int min = v[0];
  for (int i = 1; i < v.size(); i++) {
    if (v[i] < min) min = v[i];
  }
  if (m == min) return 1;
  return 0;
}
int compare(string s, string s1) {
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != s1[i]) count++;
  }
  return count;
}
string removechar(string s) {
  string s1;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '-') s1 += s[i];
  }
  return s1;
}
bool isequal(string s, string s1) {
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < s1.size(); j++) {
      if (s[i] == s1[j]) return 1;
    }
  }
  return 0;
}
int avg(vector<int> v1) {
  int sum = 0;
  for (int i = 0; i < v1.size(); i++) {
    sum += v1[i];
  }
  return sum / (v1.size());
}
bool isqeal(vector<string> v, string s) {
  for (int i = 0; i < v.size(); i++) {
    if (s == v[i]) return true;
  }
  return false;
}
bool deck1(string s) {
  int count = 0;
  int count1 = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'R')
      count++;
    else
      count1++;
  }
  if (count1 >= count) return 1;
  return 0;
}
class HuffmanDecoding {
 public:
};
bool ispower(string s) {
  if (s.size() < 10) return 0;
  if (s[0] == 'h' && s[1] == 'e' && s[2] == 'a' && s[3] == 'v' && s[4] == 'y' &&
      s[s.size() - 1] == 'l' && s[s.size() - 2] == 'a' &&
      s[s.size() - 3] == 't' && s[s.size() - 4] == 'e' &&
      s[s.size() - 5] == 'm')
    return 1;
}
bool look(string s) {
  int j = s.size() - 1;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[j]) return 0;
    j--;
  }
  return 1;
}
int main() {
  int n;
  string s;
  vector<string> v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    v.push_back(s);
  }
  for (int i = v[0].size() - 1; i >= 0; i--) {
    string s = v[0].substr(0, i);
    bool x = 1;
    for (int j = 1; j < n; j++) {
      string s1 = v[j].substr(0, i);
      if (s != s1) {
        x = 0;
        break;
      }
    }
    if (x == 1) {
      cout << s.size();
      return 0;
    }
  }
  return 0;
}
