#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define vi vector<ll>
#define vii vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) c.begin(),c.end()
#define sz(c) (ll)c.size()
#define init(x,a) memset(x,a,sizeof(x))
#define lbd(a,val) lower_bound(all(a),val)
#define ubd(a,val) upper_bound(all(a),val)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define en '\n'
#define mod (ll)1000000007
#define N 100005
ll power(ll x,ll y)
{
    if(y==0)
        return 1;
    else if(y%2 == 0)        //n is even
        return power((x*x)%mod,y/2);
    else                             //n is odd
        return (x*power((x*x)%mod,(y-1)/2))%mod;
}
int main()
{
IOS;
int t=1;
//cin>>t;
string a[16]={"0000","0001","0010","0011","0100","0101","0110","0111","1000","1001","1010","1011","1100","1101","1110","1111"};
while(t--)
{
ll n;
cin>>n;
string s[n+1];
f(i,1,n+1) cin>>s[i];
vi v;
ll cn=1;
f(i,2,n+1)
{
if(s[i]==s[i-1]) cn++;
else{
v.pb(cn);
cn=1;
}
}
ll gcd=0;
f(i,0,v.size()) gcd=__gcd(v[i],gcd);
if(gcd==1)
{
cout<<1;
return 0;
}
bool ch=0;
for(ll i=1;i<=n;i+=gcd)
{
string q="";
f(j,0,s[i].size())
{
if((s[i][j]-'0')>=0 && (s[i][j]-'0')<=9) q+=a[s[i][j]-'0'];
else q+=a[s[i][j]-'A'+10];
}
cn=1;
f(i,1,q.size())
{
if(q[i]==q[i-1]) cn++;
else if(cn!=gcd)
{
ch=1;
break;
}
else
cn=1;
}
if(ch) break;
}
if(ch) cout<<1;
else cout<<gcd;
}
}