#include<stdio.h>
#include<math.h>

#define OL(a,b) (sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)))
#define SQ(x) ((x)*(x))
typedef struct{
  double x;
  double y;
}Point;
typedef struct{
  Point p;
  double r;
}Circle;
int n;
int unko[100];
Point ps[100];
Circle middle[99];

void setC(int i,Point p1,Point p2){
  middle[i].p.x=(p1.x+p2.x)/2;
  middle[i].p.y=(p1.y+p2.y)/2;
  middle[i].r=sqrt(1-SQ(OL(middle[i].p,p1)));
}
  
int solve(){
  int i,j,max=1,ans;
  if(n==1) return 1;
  for(i=0;i<n-1;i++){
    unko[0]=i;
    for(j=i+1;j<n;j++){
      if(OL(ps[i],ps[j])<=2.0){
	unko[1]=j;
	setC(0,ps[i],ps[j]);
	ans=anus(2)+1;
	if(ans>max) max=ans;
      }
    }
  }
  return max;
}

int anus(int i){
  int c,d,max,ans;
  max=0;
  for(c=unko[i-1]+1;c<n;c++){
    if(OL(middle[i-2].p,ps[c])<=(middle[i-2].r+1.0)){
      for(d=0;d<i;d++)
	if(OL(ps[unko[d]],ps[c])>2) break;
      if(d==i){
	setC(i-1,middle[i-2].p,ps[c]);
	unko[i]=c;
	ans=anus(i+1);
	if(ans>max){
	  max=ans;
	}
      }
    }
  }
  return max+1;
}
int main(){
  int i;

  do{
    scanf("%d",&n);
    if(n==0) break;
    for(i=0;i<n;i++) scanf("%lf,%lf",&(ps[i].x),&(ps[i].y));
    printf("%d\n",solve());

  }while(1);
  return 0;
}
      