//Overlaps of Seals
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

vector<P> v;
vector<vector<int> > v2;

//重なっていたらtrue
bool pile(P a, P b){
  return abs(a-b)<=2.0;
}

int pile_n(vector<int> a, vector<int> b){
  int n=0, ap=0, bp=0;
  while(ap<a.size() && bp<b.size()){
    if(a[ap]==b[bp]){n++; ap++; bp++;}
    else if(a[ap]<b[bp]){
      while(a[ap]<b[bp] || ap<a.size())ap++;
    }
    else if(a[ap]>b[bp]){
      while(a[ap]>b[bp] || bp<b.size())bp++;
    }
  }
  return n;
}

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    v.clear();
    for(int i=0; i<n; i++){
      P tmp;
      scanf("%lf,%lf", &tmp.real(), &tmp.imag());
      v.push_back(tmp);
    }
    for(int i=0; i<n; i++){
      vector<int> tmp;
      for(int j=0; j<n; j++){
        if(pile(v[i], v[j]))tmp.push_back(j);
      }
      v2.push_back(tmp);
    }

    int max=0;
    for(int i=0; i<n-1; i++){
      for(int j=i+1; j<n; j++){
        int m=pile_n(v2[i], v2[j]);
        if(max<m)max=m;
      }
    }
    cout<<max<<endl;
  }
  return 0;
}