#include <bits/stdc++.h>
using namespace std;
int a[150][150];
int b[150][150];
int main() {
  int n, m;
  while (cin >> n >> m) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
    }
    int ans;
    for (ans = 1; ans <= n; ans++) {
      int tmp = n, cao = 1;
      if (n % ans != 0) continue;
      if (ans == n) break;
      while (tmp > ans) tmp /= 2, cao++;
      if (tmp != ans) continue;
      int ok = true;
      int row = ans;
      for (int i = 1; i <= row; i++)
        for (int j = 1; j <= m; j++) b[i][j] = a[i][j];
      while (cao--) {
        for (int i = row + 1; i <= 2 * row; i++)
          for (int j = 1; j <= m; j++) b[i][j] = b[row + 1 - (i - row)][j];
        row *= 2;
      }
      if (row != 2 * n) ok = false;
      for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
          if (a[i][j] != b[i][j]) ok = false;
      if (ok) break;
    }
    cout << ans << endl;
  }
  return 0;
}
