#include <bits/stdc++.h>
using namespace std;
int mas[110][110];
int n, m;
bool equal(int s) {
  for (int i = 0; i < s; i++) {
    for (int j = 0; j < m; j++) {
      if (mas[i][j] != mas[n - i - 1][j]) return false;
    }
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  if (n % 2) {
    printf("%d\n", n);
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &mas[i]);
    }
  }
  if (equal(n / 2))
    n /= 2;
  else {
    printf("%d\n", n);
    return 0;
  }
  while (equal(n)) {
    if (n % 2) break;
    n /= 2;
  }
  printf("%d\n", n);
}
