#include <bits/stdc++.h>
using namespace std;
int n, m;
bool isSym(int** a) {
  if (n % 2 == 1) return false;
  int mid = n / 2;
  for (int i = 0; i < mid; i++)
    for (int j = 0; j < m; j++) {
      if (a[i][j] != a[n - i - 1][j]) return false;
    }
  return true;
}
int main() {
  cin >> n >> m;
  int** a = new int*[n];
  for (int i = 0; i < n; ++i) a[i] = new int[m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  while (true) {
    if (isSym(a)) {
      n = n / 2;
    } else
      break;
  }
  cout << n << endl;
  return 0;
}
