#include <bits/stdc++.h>
int a[105][105];
int fun(int n, int m) {
  int cnt = 0, i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (a[i][j] == a[n - i + 1][j]) {
        cnt++;
      }
    }
  }
  if (cnt == (n * m)) {
    return 1;
  } else
    return 0;
}
int main() {
  int t, n, i, m, j, k;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  while (n % 2 == 0) {
    t = fun(n, m);
    if (t == 1)
      n = n / 2;
    else
      break;
  }
  printf("%d", n);
  return 0;
}
