#include <bits/stdc++.h>
using namespace std;
const long long oo = (long long)1e18;
const int ooi = (int)1e7;
char arr[109][109];
int x, y, ans;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> x >> y;
  for (int i = 0; i < x; i++)
    for (int j = 0; j < y; j++) cin >> arr[i][j];
  ans = x;
  bool con = true;
  while (!(ans % 2) && con) {
    ans /= 2;
    for (int i = 0; (i < ans) && con; i++)
      for (int j = 0; j < y && con; j++) {
        if (arr[ans - i - 1][j] != arr[i + ans][j]) {
          con = false;
        }
      }
    if (con) x = ans;
  }
  cout << x << endl;
  return 0;
}
