#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  if (n & 1) {
    cout << n;
    return 0;
  }
  string arr[n];
  string t;
  int i = 0;
  string *head = NULL, *end = NULL;
  getline(cin, t);
  for (; i < n; i++) {
    getline(cin, t);
    arr[i] = t;
  }
  while (!(n & 1)) {
    head = arr;
    end = arr + n - 1;
    while (end > head) {
      if (*end != *head) {
        cout << n << endl;
        return 0;
      }
      end--;
      head++;
    }
    n >>= 1;
  }
  cout << n << endl;
  return 0;
}
