#include <bits/stdc++.h>
using namespace std;
const int maxn = 120;
int f[maxn][maxn];
int main() {
  int n, m;
  while (cin >> n >> m) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) cin >> f[i][j];
    if (n % 2) {
      cout << n << endl;
      continue;
    }
    int mid = n;
    while (1) {
      int flag = 0;
      for (int i = 1; i <= mid / 2; i++) {
        for (int j = 1; j <= m; j++) {
          if (f[i][j] != f[mid + 1 - i][j]) {
            flag = 1;
            break;
          }
        }
        if (flag) break;
      }
      if (flag) break;
      mid = mid / 2;
      if (mid % 2) break;
    }
    cout << mid << endl;
  }
  return 0;
}
