#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010;
const int mod = 100007;
const int N = 500 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1);
int n, m, cnt, ans, flag;
inline int read() {
  register int c = getchar(), fg = 1, sum = 0;
  while (c > '9' || c < '0') {
    if (c == '-') fg = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return fg * sum;
}
string a[123];
int nxt[123];
void get_nxt() {
  int i = 0;
  int j = -1;
  nxt[0] = -1;
  while (i < n) {
    if (j == -1 || a[i] == a[j]) {
      i++;
      j++;
      nxt[i] = j;
    } else
      j = nxt[j];
  }
}
void init() {
  n = read();
  m = read();
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) a[i] += (read() + 48);
}
void go() {
  get_nxt();
  m = n - nxt[n];
  if (n % m) m = n;
  for (int i = 0; i < m / 2; i++)
    if (a[i] != a[m - i - 1]) {
      printf("%d\n", n);
      return;
    }
  if (m % 2 == 0) m /= 2;
  while (n % 2 == 0 && n > m) n /= 2;
  printf("%d\n", n);
}
int main() {
  init();
  go();
}
