#include <bits/stdc++.h>
using namespace std;
long long ans, res, p, q, x;
void solve() {
  int n, m;
  cin >> n >> m;
  int cnt[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> cnt[i][j];
    }
  }
  if (n % 2) {
    cout << n << "\n";
    return;
  } else {
    while (n % 2 == 0) {
      for (int i = 0; i < n / 2; i++) {
        for (int j = 0; j < m; j++) {
          if (cnt[i][j] == cnt[n - i - 1][j])
            continue;
          else {
            cout << n << "\n";
            return;
          }
        }
      }
      n /= 2;
    }
  }
  cout << n << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tt = 1;
  while (tt--) solve();
}
