#include <bits/stdc++.h>
using namespace std;
int s[200][200];
int n, m;
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 0; i < n; i++)
      for (int k = 0; k < m; k++) scanf("%d", &s[i][k]);
    if (n % 2)
      printf("%d\n", n);
    else {
      int t = n;
      while (1) {
        int f = 1;
        for (int i = 0; i < t / 2; i++) {
          for (int k = 0; k < m; k++) {
            if (s[i][k] != s[t - 1 - i][k]) {
              f = 0;
              break;
            }
          }
        }
        if (f == 1) {
          if (t % 2 == 1) break;
          t /= 2;
        } else if (f == 0)
          break;
      }
      printf("%d\n", t);
    }
  }
  return 0;
}
