#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100][100];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  int mx = 0;
  for (int i = 1; i < 100; i *= 2) {
    if (n % i == 0) {
      int per = n / i;
      bool ok = true;
      for (int j = 0; j < m; j++) {
        vector<int> tmp;
        for (int u = 0; u < per; u++) tmp.push_back(a[u][j]);
        while (tmp.size() < n) {
          int k = tmp.size();
          for (int v = 0; v < k; v++) {
            tmp.push_back(tmp[k - 1 - v]);
          }
        }
        for (int u = 0; u < n; u++) {
          if (a[u][j] != tmp[u]) ok = false;
        }
      }
      if (ok) mx = per;
    }
  }
  cout << mx << endl;
}
