#include <bits/stdc++.h>
using namespace std;
long long x, y, z, i, j, n, m, k, s1, s2, s3, s4, s5, mod, l, r, t, maxx, minn,
    sx, so, sum, ans, puk;
double u, v, w, x1, x2, x3, z1, z2, z3, h, huh;
string ss1;
string ss2;
string ss3;
string ss4;
long long a[145][145];
long long b[200045];
vector<long long> vc;
vector<long long> cv;
vector<long long> cvc;
int main() {
  scanf("%lld%lld", &n, &m);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      scanf("%lld", &a[i][j]);
    }
  }
  while (so < 1) {
    if (n % 2 == 1) {
      printf("%lld", n);
      exit(0);
    }
    x = 0;
    for (i = 1; i <= n / 2; i++) {
      for (j = 1; j <= m; j++) {
        if (a[i][j] == a[n + 1 - i][j]) x++;
      }
    }
    if (x == n * m / 2) {
      n /= 2;
    } else {
      printf("%lld", n);
      exit(0);
    }
  }
}
