#include <bits/stdc++.h>
char s[105][105];
int b[105][105];
int main() {
  int n, m;
  int a[100] = {0};
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &b[i][j]);
    }
  }
  int o = 1;
  int flag = 0;
  for (int i = 1; i < n; i++) {
    if (n % i == 0) {
      int d = i;
      while (d < n) {
        d = d * 2;
      }
      if (d == n) {
        a[o++] = i;
      } else {
        continue;
      }
    }
  }
  int ans = 0;
  for (int i = o - 1; i > 0; i--) {
    int ret = 0;
    for (int j = 1; j <= n - a[i]; j = j + a[i]) {
      int d = 0;
      for (int k = j; k < j + a[i]; k++) {
        d++;
        int re = 0;
        for (int l = 1; l <= m; l++) {
          if (b[k][l] == b[j + 2 * a[i] - d][l]) {
            re++;
          }
        }
        if (re == m) {
          ret++;
        }
      }
      if (ret < a[i]) {
        break;
      }
    }
    if (ret == n - a[i]) {
      ans = a[i];
    }
    ret = 0;
  }
  if (ans == 0) {
    printf("%d\n", n);
    return 0;
  }
  printf("%d\n", ans);
}
