#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  t = 1;
  while (t--) {
    long long n, m;
    cin >> n;
    cin >> m;
    string s[n];
    for (long long i = 0; i < n; i++) {
      string cur = "";
      for (long long i = 0; i < m; i++) {
        long long k;
        cin >> k;
        cur += to_string(k);
      }
      s[i] = cur;
    }
    if (n & 1)
      cout << n << endl;
    else {
      long long ans = n;
      while (n % 2 == 0) {
        n = n / 2;
        bool flag = 1;
        for (long long i = 0; i < n; i++) {
          if (s[i] != s[2 * n - i - 1]) {
            flag = 0;
            break;
          }
        }
        if (!flag)
          break;
        else
          ans = n;
      }
      cout << ans << endl;
    }
  }
  return 0;
}
