#include <bits/stdc++.h>
using namespace std;
int arr[100000 + 10];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<string> b1, b2;
  if (n % 2) {
    cout << n << endl;
    return 0;
  } else {
    string tmp;
    char ch;
    int ans = n;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> ch;
        tmp.push_back(ch);
      }
      b1.push_back(tmp);
      tmp.clear();
    }
    while (1) {
      int z = b1.size() / 2, t = b1.size() - 1;
      for (int i = t; i >= z; i--) {
        b2.push_back(b1[i]);
        b1.pop_back();
      }
      if (b1 == b2)
        ans = min(ans, (int)b1.size());
      else
        break;
      b2.clear();
    }
    cout << ans << endl;
  }
  return 0;
}
