#include <bits/stdc++.h>
long long a[1000][200];
long long n, m;
int cmp(const void* a, const void* b) {
  return *(long long*)b - *(long long*)a;
}
long long as(long long x) {
  for (long long i = 1; i <= x; i++) {
    for (long long j = 1; j <= m; j++) {
      if (a[i][j] != a[x * 2 - i + 1][j]) {
        return x * 2;
      }
    }
  }
  if (x == 1) {
    return 1;
  }
  if (x % 2 == 1) {
    return x;
  }
  return as(x / 2);
}
int main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      scanf("%lld", &a[i][j]);
    }
  }
  if (n % 2 == 1) {
    printf("%lld", n);
  } else {
    printf("%lld", as(n / 2));
  }
  return 0;
}
