#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  int m;
  std::cin >> m;
  std::vector<std::vector<int>> a;
  int x;
  for (int i = 0; i < n; i++) {
    std::vector<int> next;
    for (int j = 0; j < m; j++) {
      std::cin >> x;
      next.push_back(x);
    }
    a.push_back(next);
  }
  int rows = n;
  bool can_minimize = true;
  while (can_minimize) {
    if (rows % 2 != 1)
      for (int i = 0; i < rows / 2; i++) {
        for (int j = 0; j < m; j++)
          if (a[i][j] != a[rows - i - 1][j]) can_minimize = false;
      }
    else
      can_minimize = false;
    if (can_minimize) rows /= 2;
  }
  std::cout << rows;
}
