#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, p[110][110], i, j;
  string ko[110];
  while (cin >> n >> m) {
    for (i = 0; i < n; i++)
      for (j = 0; j < m; j++) cin >> p[i][j];
    for (i = 0; i < n; i++) {
      ko[i] = "";
      for (j = 0; j < m; j++) ko[i] += '0' + p[i][j];
    }
    if (n % 2) {
      cout << n << endl;
      continue;
    }
    int len = n;
    while (len % 2 == 0) {
      int pp = 0;
      for (i = 0; i < len / 2; i++)
        if (ko[i] != ko[len - 1 - i]) {
          pp = 1;
          break;
        }
      if (pp == 0)
        len /= 2;
      else
        break;
    }
    cout << len << endl;
  }
}
