#include <bits/stdc++.h>
using namespace std;
int sym(int a[][111], int sz, int m) {
  int i, j;
  if (sz % 2 == 1) return 0;
  for (i = 1; i <= sz / 2; i++) {
    for (j = 1; j <= m; j++) {
      if (a[i][j] == a[sz - i + 1][j])
        ;
      else
        return 0;
    }
  }
  return 1;
}
int main() {
  int i, j, n, m;
  int a[111][111];
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> a[i][j];
  while (3) {
    if (sym(a, n, m) == 1) {
      n = n / 2;
    } else
      break;
  }
  cout << n << endl;
}
