#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int xChange[] = {0, 1, 0, -1};
int yChange[] = {1, 0, -1, 0};
const int N = 100;
int n, m;
string a[N];
vector<string> vo, vm, vmt;
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL);
  cin >> n >> m;
  cin.ignore();
  for (int i = 0; i < n; i++) getline(cin, a[i]);
  if (n & 1) {
    cout << n;
    return 0;
  } else {
    for (int i = 0; i < n; i++) {
      vo.push_back(a[i]);
      vm.push_back(a[i]);
      bool flag = true;
      int idx = (int)vo.size();
      vmt = vm;
      reverse(vmt.begin(), vmt.end());
      for (int j = 0; j < n; j++) {
        for (int h = 0; h < idx; h++, j++)
          if (vo[h] != a[j]) {
            flag = false;
            break;
          }
        if (flag) {
          for (int g = 0; g < idx; g++, j++)
            if (vmt[g] != a[j]) {
              flag = false;
              break;
            }
        }
        if (!flag) break;
        j--;
      }
      if (flag) {
        while (n % 2 == 0) n /= 2;
        cout << max((i + 1), n);
        return 0;
      }
    }
  }
  cout << n;
  return 0;
}
