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