#include <bits/stdc++.h>
using namespace std;
int a[120][120];
int n, m;
inline int judge(int i, int j) {
  while (i < j) {
    for (int k = 1; k <= m; k++)
      if (a[i][k] != a[j][k]) return 0;
    i++;
    j--;
  }
  return 1;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    int nn = n;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
    }
    if (n % 2 != 0) {
      printf("%d\n", nn);
      continue;
    }
    int ans = 0;
    while (judge(1, n) == 1) {
      ans = n / 2;
      n = n / 2;
      if (n % 2 != 0) break;
    }
    if (ans == 0)
      printf("%d\n", nn);
    else
      printf("%d\n", ans);
  }
  return 0;
}
