#include <bits/stdc++.h>
using namespace std;
const int maxn = 500;
int a[maxn][maxn];
int n, m;
int check(int tn) {
  if (tn & 1) return 0;
  int flag = 0;
  int half = tn / 2;
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= half; i++) {
      if (a[i][j] != a[tn + 1 - i][j]) {
        flag = 1;
        break;
      }
    }
  }
  if (flag) return 0;
  return 1;
}
int main() {
  int s, i, j;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) cin >> a[i][j];
    }
    if (check(n)) {
      int tn = n / 2;
      while (check(tn)) {
        tn /= 2;
        check(tn);
      }
      printf("%d\n", tn);
    } else
      printf("%d\n", n);
  }
  return 0;
}
