#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }
  if (n % 2 == 1)
    cout << n;
  else {
    while (1) {
      for (int i = n / 2 - 1; i >= 0; i--) {
        for (int j = 0; j < m; j++) {
          if (a[i][j] != a[n - i - 1][j]) {
            cout << n;
            return 0;
          }
        }
      }
      if (n % 2 == 1) {
        cout << n;
        return 0;
      }
      n /= 2;
    }
  }
  return 0;
}
