#include <bits/stdc++.h>
int a[105][105];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  int ans = n;
  if (n & 1)
    printf("%d\n", n);
  else {
    int p = n;
    while (p % 2 == 0) {
      p >>= 1;
      bool flag = true;
      for (int i = 1; i <= p && flag; i++)
        for (int j = 1; j <= m && flag; j++)
          if (a[i][j] != a[p * 2 - i + 1][j]) flag = false;
      if (flag)
        ans >>= 1;
      else
        break;
    }
    printf("%d\n", ans);
  }
}
