#include <bits/stdc++.h>
using namespace std;
const int INIT_SIZE_MAX = (1 << 29) + 10;
const int INIT_SIZE_MIN = -(1 << 29) - 10;
const int INIT_SIZE = 0;
const int MAX = 8;
const int DIR_SIZE = 12;
const double PI = 3.1415926535897932384;
template <class T, class U>
void convert(T &t, U &u) {
  stringstream ss;
  ss << t;
  ss >> u;
}
int dfs(int pos, vector<vector<int> > &tb) {
  if (pos % 2) return pos;
  int half = pos / 2;
  int res = 0;
  for (int(i) = 0; (i) < (half); ++(i)) {
    bool f = true;
    for (int(j) = 0; (j) < (tb[0].size()); ++(j)) {
      if (tb[0 + i][j] != tb[(pos - 1) - i][j]) {
        f = false;
        break;
      }
    }
    if (f) {
      res = dfs(pos / 2, tb);
    } else {
      return pos;
    }
  }
  return res;
}
int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int> > tb(h, vector<int>(w, 0));
  for (int(i) = 0; (i) < (h); ++(i))
    for (int(j) = 0; (j) < (w); ++(j)) cin >> tb[i][j];
  if (h % 2) {
    cout << h << endl;
    return 0;
  }
  int ans = 1 << 29;
  ans = min(ans, dfs(h, tb));
  cout << ans << endl;
}
