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