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