#include <bits/stdc++.h>
using namespace std;
int a[102][102];
int n, m, q;
int rec(int n) {
  if (n & 1) return n;
  int t = n / 2;
  for (int i = 1; i <= t; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i][j] != a[n + 1 - i][j]) return n;
  n /= 2;
  return rec(n);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) cin >> a[i][j];
  cout << rec(n) << endl;
  return 0;
}
