#include <bits/stdc++.h>
const long long inf = 0x3f3f3f3f3f3f3f3LL;
const long long mod = (long long)1e9 + 7;
using namespace std;
template <class T>
void smin(T& a, T val) {
  if (a > val) a = val;
}
template <class T>
void smax(T& a, T val) {
  if (a < val) a = val;
}
const long long N = 100 + 10;
long long n, a[N][N], m;
long long check(long long n) {
  if (n % 2) return n;
  bool good = 1;
  for (long long i = n / 2; i >= 1; --i) {
    for (long long j = 1; j <= m; ++j) {
      good &= (a[i][j] == a[n - i + 1][j]);
    }
  }
  if (good) return check(n / 2);
  return n;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= m; ++j) {
      cin >> a[i][j];
    }
  }
  cout << check(n);
  return 0;
}
