#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int martrix[n + 1][m + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> martrix[i][j];
    }
  }
  int ans = n;
  if (ans % 2 == 0) {
    int flag = 0;
    while (flag == 0 && ans > 1 && ans % 2 == 0) {
      for (int i = 1, j = ans; i <= ans / 2; i++, j--) {
        for (int t = 1; t <= m; t++) {
          if (martrix[i][t] != martrix[j][t]) {
            flag = 1;
            break;
          }
        }
        if (flag == 1) {
          break;
        }
      }
      if (flag == 0) {
        ans = ans / 2;
      }
    }
  }
  cout << ans;
}
