#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<int> > v(n, vector<int>(m));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", &v[i][j]);
  if (n % 2) return 0 * printf("%d\n", n);
  int c = 0;
  int tem = n;
  while (!(tem % 2)) {
    for (int i = 0; i < tem / 2; ++i) {
      for (int j = 0; j < m; ++j)
        if (v[i][j] != v[tem - i - 1][j]) c++;
    }
    if (c) break;
    tem /= 2;
  }
  printf("%d\n", tem);
  return 0;
}
