#include <bits/stdc++.h>
using namespace std;
bool simetrik(vector<vector<bool>> &V, int n) {
  if (n % 2 == 0) {
    for (int i = 0; i < n - i; ++i) {
      if (V[i] != V[n - i - 1]) return false;
    }
    return true;
  }
  return false;
}
int main() {
  int n, i, j, m;
  bool item;
  cin >> n >> m;
  vector<vector<bool>> V(n, vector<bool>(m));
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      cin >> item;
      V[i][j] = item;
    }
  }
  while (simetrik(V, n)) {
    n /= 2;
  }
  cout << n << endl;
  return 0;
}
