#include <bits/stdc++.h>
int check_matrix(int** arr, int n, int m) {
  int itN = 0, itJ = n - 1;
  if (n % 2) return n;
  while (itN < itJ) {
    for (int i = 0; i < m; ++i)
      if (arr[itN][i] != arr[itJ][i]) return n;
    itN++;
    itJ--;
  }
  return check_matrix(arr, n / 2, m);
}
int main() {
  int n, m, **arr;
  std::cin >> n >> m;
  arr = new int*[n];
  for (int i = 0; i < n; ++i) *(arr + i) = new int[m];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) std::cin >> arr[i][j];
  std::cout << check_matrix(arr, n, m);
  for (int i = 0; i < n; ++i) delete[] * (arr + i);
  delete[] arr;
}
