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