#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, m, b[N][N], a[N][N];
void solve() {
  if (n % 2) {
    printf("%d\n", n);
    return;
  }
  bool ok = 1;
  while (n > 1 && ok && n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (b[i][j] != b[n - i - 1][j]) {
          ok = 0;
          break;
        }
      }
    }
    if (ok) n /= 2;
  }
  printf("%d\n", n);
}
int main() {
  ios::sync_with_stdio(false);
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &b[i][j]);
  solve();
  return 0;
}
