#include <bits/stdc++.h>
using namespace std;
int mat[105][105];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &mat[i][j]);
  int k = 2;
  while (n % k == 0) {
    int flag = 1;
    for (int j = 1; j <= m; j++)
      for (int i = 1; i <= n / k; i++)
        if (mat[i][j] != mat[2 * n / k - i + 1][j]) {
          flag = 0;
          break;
        }
    if (!flag) break;
    k *= 2;
  }
  k /= 2;
  printf("%d\n", n / k);
}
