#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
const int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
const int dy[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
int n, m, a[111][111], ar[111][111];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  clock_t z = clock();
  cin >> n >> m;
  if (n & 1) return cout << n << endl, 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  int t = 0, b = n - 1, cntr = n / 2, mn = n;
  while (1) {
    int c = 0, j = 0;
    while (t <= b) {
      for (int j = 0; j < m; j++)
        if (a[t][j] == a[b][j]) c++;
      if (c == m) j++;
      c = 0;
      t++;
      b--;
    }
    int i = 0;
    for (int i = 0; i < j; i++)
      for (int jj = 0; jj < m; jj++) ar[i][jj] = a[i][jj];
    for (int ii = n - 1; ii >= j; ii--) {
      for (int jj = 0; jj < m; jj++) ar[ii][jj] = a[i][jj];
      i++;
      if (i == j) i = 0;
    }
    bool f = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (a[i][j] != ar[i][j]) f = 1;
    if (f) break;
    if (j == cntr)
      mn = j;
    else
      break;
    t = 0, b = n / 2 - 1;
    n /= 2;
    cntr = n / 2;
  }
  cout << mn << endl;
  fprintf(stderr, "Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC),
      fflush(stderr);
  return 0;
}
