#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long power(long long a, long long b, long long modi) {
  long long res = 1;
  while (b) {
    if (b % 2) {
      res = (res * a) % modi;
    }
    b /= 2;
    a = (a * a) % modi;
  }
  return res;
}
int dirx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int diry[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
long long n, m;
long long cur, sum, res, ans = 0;
long long a[1000005], b[1000005], c[1000005];
vector<long long> vt;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int flag = 0;
  char ch;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n / 4; j++) {
      cin >> ch;
      if (ch == '0') {
        if (flag == 0 || flag == 1)
          flag = 1;
        else
          flag = 3;
      } else if (ch == 'F') {
        if (flag == 0 || flag == 2)
          flag = 2;
        else
          flag = 3;
      } else {
        flag = 3;
      }
    }
  }
  if (flag == 3)
    cout << "1";
  else
    cout << n << endl;
  return 0;
}
