#include <bits/stdc++.h>
using namespace std;
int a[110][110];
signed main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  if (n % 2 == 1)
    printf("%d\n", n);
  else {
    int len = n;
    while (1) {
      bool flag = 1;
      for (int i = 0; i < len / 2; i++) {
        for (int j = 0; j < m; j++) {
          if (a[i][j] != a[len - 1 - i][j]) flag = 0;
        }
      }
      if (flag) {
        if (len % 2) {
          break;
        }
        len /= 2;
      } else {
        break;
      }
    }
    printf("%d\n", len);
  }
  return 0;
}
