#include <bits/stdc++.h>
using namespace std;
int n, m, s[101][101];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &s[i][j]);
  while (n > 0 && n % 2 == 0) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (s[i][j] != s[n - 1 - i][j]) goto hell;
    n /= 2;
  }
hell:;
  printf("%d\n", n);
  return 0;
}
