#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int base = 1000000007;
const int N = 1e5 + 5;
int n, m;
vector<vector<int> > v;
bool chk(int x) {
  vector<vector<int> > vv;
  for (int i = 0; i < x; ++i) vv.push_back(v[i]);
  while (v.size() != vv.size()) {
    vector<vector<int> > rv = vv;
    reverse(rv.begin(), rv.end());
    for (auto x : rv) vv.push_back(x);
  }
  return v == vv;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    vector<int> a(m);
    for (int &e : a) cin >> e;
    v.push_back(a);
  }
  vector<int> vec;
  while (n % 2 == 0) {
    vec.push_back(n);
    n /= 2;
  }
  vec.push_back(n);
  reverse(vec.begin(), vec.end());
  for (int x : vec)
    if (chk(x)) return !printf("%d\n", x);
}
