#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 123;
const long long INF = (long long)1e18 + 123;
const int inf = (int)1e9 + 123;
int n, m;
int a[111][111];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  while (n % 2 == 0) {
    for (int i = 1, r = n; i <= (n >> 1); i++, r--)
      for (int j = 1; j <= m; j++)
        if (a[i][j] != a[r][j]) goto go;
    n >>= 1;
  }
go:;
  cout << n;
  return 0;
}
