#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, rows, cnt = 0;
  cin >> n >> m, rows = n;
  cin.ignore();
  vector<string> matrix(n);
  for (int i = 0; i < n; i++) getline(cin, matrix[i]);
  if (n % 2 != 0)
    cout << rows;
  else {
    while (1) {
      cnt = 0;
      for (int i = 0; i < n / 2; i++)
        if (matrix[i] == matrix[n - i - 1]) cnt++;
      if (cnt == n / 2) rows -= n / 2;
      if (cnt != n / 2 || (n / 2) % 2 != 0) break;
      n /= 2;
    }
    cout << rows;
  }
  return 0;
}
