#include <bits/stdc++.h>
using namespace std;
int getint() {
  unsigned int c;
  int x = 0;
  while (((c = getchar()) - '0') >= 10) {
    if (c == '-') return -getint();
    if (!~c) exit(0);
  }
  do {
    x = (x << 3) + (x << 1) + (c - '0');
  } while (((c = getchar()) - '0') < 10);
  return x;
}
int sym(int x, int n) { return n - x - 1; }
int n, m;
int a[111][111];
int main() {
  int i, j, tcc, tc = 1 << 28;
  for (tcc = 0; tcc < tc; tcc++) {
    n = getint(), m = getint();
    for (i = 0; i < n; i++)
      for (j = 0; j < m; j++) a[i][j] = getint();
    for (; n % 2 == 0; n /= 2) {
      int ok = 1;
      for (i = 0; i < n / 2; i++)
        for (j = 0; j < m; j++) {
          int x = sym(i, n), y = j;
          if (a[i][j] != a[x][y]) {
            ok = 0;
            break;
          }
        }
      if (!ok) break;
    }
    cout << n << endl;
  }
  return 0;
}
