#include <bits/stdc++.h>
using namespace std;
int r, c, B[111][111];
bool canMirror(int rows) {
  int o = 2 * rows - 1;
  for (int i = 0; i < rows; i++) {
    for (int j = 0; j < c; j++) {
      if (B[i][j] != B[o - i][j]) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  while (cin >> r >> c) {
    for (int i = 0; i < r; i++) {
      for (int j = 0; j < c; j++) {
        cin >> B[i][j];
      }
    }
    int rr = r;
    while (rr >= 2 && rr % 2 == 0 && canMirror(rr / 2)) {
      rr /= 2;
    }
    cout << rr << endl;
  }
}
