#include <bits/stdc++.h>
using namespace std;
int n, m, matrix[102][102];
int main() {
  scanf("%d%d", &n, &m);
  for (int ix1 = 1; ix1 <= n; ix1++)
    for (int ix2 = 1; ix2 <= m; ix2++) scanf("%d", &matrix[ix1][ix2]);
  while (n % 2 == 0) {
    int mid = n >> 1;
    bool ok = true;
    for (int i = 0; i <= mid - 1; i++) {
      for (int ix = 1; ix <= m; ix++)
        if (matrix[mid - i][ix] != matrix[mid + i + 1][ix]) {
          ok = false;
          break;
        }
      if (!ok) break;
    }
    if (!ok) break;
    n >>= 1;
  }
  cout << n << endl;
}
