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