#include <bits/stdc++.h>
using namespace std;
long long ar[1005][1005], br[1005][1005], fr[555];
string s[555];
string s1, s2;
int main() {
  long long i, j, k, m, n, r, c;
  while (cin >> r >> c) {
    getchar();
    s[0] = "";
    for (i = 1; i <= r; i++) {
      getline(cin, s[i]);
    }
    n = r;
    if (n & 1) {
      cout << n << endl;
      continue;
    }
    while (n > 0) {
      i = 1;
      j = n;
      while (s[i] == s[j]) {
        i++, j--;
        if (i > j) break;
      }
      if (i > j)
        n /= 2;
      else {
        cout << n << endl;
        return 0;
      }
      if (n & 1) {
        cout << n << endl;
        return 0;
      }
    }
    cout << 1 << endl;
  }
  return 0;
}
