def dist2(pt1,pt2):
    return ((pt1[0]-pt2[0])**2+(pt1[1]-pt2[1])**2)<=4


while(1):
    n=int(raw_input())
    if n==0:
        break
    else:
        plist=[]
        for i in range(n):
            plist.append([float(x) for x in raw_input().split(',')])
        graphlist=[]
        for i in range(n):
            gilist=[]
            for j in range(n):
                if i!=j and dist2(plist[i],plist[j]):
                    gilist.append(j)
            graphlist.append(gilist)
        maxcreek=[[x] for x in range(n)]
        while(1):
            newmaxcreek=[]
            for creek in maxcreek:
                pt=creek[0]
                for p in [x for x in graphlist[pt] if x not in creek]:
                    for pts in creek[1:]:
                        if p not in graphlist[pts]:
                            break
                    else:
                        newmaxcreek.append(creek+[p])
            if len(newmaxcreek)==0:
                print max(map(len,maxcreek))
                break
            else:
                maxcreek=newmaxcreek[:]