#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[105][105];
bool row(int i, int j) {
  bool flag = true;
  for (int k = 0; k < m; k++) {
    if (a[i][k] != a[j][k]) flag = false;
  }
  return flag;
}
bool check(int i) {
  bool flag;
  int sum = 0;
  for (int j = 1; j < i; j++) {
    if (row(0, j)) sum++;
  }
  if (sum == (i - 1))
    flag = true;
  else
    flag = false;
  return flag;
}
int main(void) {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }
  if (n % 2 != 0)
    cout << n << endl;
  else {
    int ans;
    int s = 2 * n;
    while (s == (s / 2) * 2 && s > 0) {
      s = s / 2;
      if (s != (s / 2) * 2) {
        break;
      }
      int flag = 0;
      for (int i = 0; i < s / 2; i++) {
        if (row(i, s - i - 1))
          ;
        else
          flag = 1;
      }
      if (flag == 1) break;
    }
    cout << s << endl;
  }
  return 0;
}
