#include <bits/stdc++.h>
using namespace std;
template <typename T>
void PrintContainer(T& a, int n = -1) {
  if (n == -1) n = a.size();
  cout << "{";
  int i = 0;
  for (auto it : a) {
    cout << (it) << ", ";
    if (++i == n) break;
  }
  cout << "}\n";
}
int go(vector<vector<int> >& M, int rows) {
  if (rows % 2) return rows;
  bool good = true;
  for (int r = 0; r < (int)(rows); ++r)
    for (int c = 0; c < (int)(M[0].size()); ++c)
      good &= (M[r][c] == M[rows - 1 - r][c]);
  if (good) return go(M, rows / 2);
  return rows;
}
int main() {
  int R, C;
  cin >> R >> C;
  vector<vector<int> > M(R, vector<int>(C));
  for (int r = 0; r < (int)(R); ++r)
    for (int c = 0; c < (int)(C); ++c) cin >> M[r][c];
  cout << go(M, R) << endl;
}
