#include <bits/stdc++.h>
using namespace std;
int main() {
  int maxx = -1, n, m, sum = 0, k, n1, i, j, flot = 1, flag = 1;
  int a[150][150];
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  if (n % 2) {
    cout << n << endl;
  } else {
    for (int k = 1; k <= m; k++) {
      int e = 0;
      int b[150];
      memset(b, 0, sizeof(b));
      for (i = 1; i <= n; i++) {
        b[e] = a[i][k];
        e++;
      }
      n1 = n;
      flot = 1;
      while (1) {
        for (i = 0; i < n1 / 2; i++) {
          if (b[i] != b[n1 - 1 - i]) {
            flot = 0;
            break;
          }
        }
        if (flot) {
          if (n1 % 2) break;
          n1 /= 2;
        } else
          break;
        if (n1 == 1) {
          break;
        }
      }
      maxx = max(maxx, n1);
    }
    cout << maxx << endl;
  }
  return 0;
}
