#include <bits/stdc++.h>
using namespace std;
int A[200][200];
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int n, m, i, j, k, x, y, z;
  cin >> n >> m;
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      cin >> A[i][j];
    }
  }
  for (i = 1; i <= n; ++i) {
    if ((n % i != 0) || (__builtin_popcount(n / i) != 1)) continue;
    x = 0;
    y = i * 2 - 1;
    if (y >= n) break;
    while (x < y) {
      for (j = 0; j < m; ++j) {
        if (A[x][j] != A[y][j]) break;
      }
      if (j != m) break;
      x++;
      y--;
    }
    if (x < y) {
      continue;
    }
    for (j = 0; j < n; j += 2 * i) {
      for (x = j; x < j + 2 * i; ++x) {
        for (y = 0; y < m; ++y) {
          if (A[x][y] != A[x - j][y]) break;
        }
        if (y < m) break;
      }
      if (y < m) break;
    }
    if (j >= n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << n << endl;
  return 0;
}
