#include <bits/stdc++.h>
using namespace std;
int a[110][110];
int main() {
  int n, m, i, j;
  while (~scanf("%d %d", &n, &m)) {
    for (i = 0; i < n; i++)
      for (j = 0; j < m; j++) scanf("%d", &a[i]);
    if (n & 1) {
      cout << n << endl;
      continue;
    }
    int vis;
    for (i = 0; i < m; i++) {
      for (j = 0, vis = 0; j < n; j++) {
        if (a[j][i] != a[n - j - 1][i]) {
          vis = 1;
          break;
        }
      }
      if (vis) break;
    }
    if (vis)
      cout << n << endl;
    else {
      while (1) {
        n /= 2;
        if (n == 1 || (n & 1)) {
          cout << n << endl;
          break;
        }
        for (i = 0; i < m; i++) {
          for (j = 0, vis = 0; j < n; j++) {
            if (a[j][i] != a[n - j - 1][i]) {
              vis = 1;
              break;
            }
          }
          if (vis) break;
        }
        if (vis) {
          cout << n << endl;
          break;
        }
      }
    }
  }
  return 0;
}
