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