#include <cstdio>
#include <cmath>
#include <complex>

#define MAX 101
#define EPS 1e-5

typedef std::complex<double> P;
P p[MAX];

int n;

int main(){
    while(scanf("%d", &n)){
        if(n == 0) break;

        for(int i = 0; i < n; i++){
            double a, b;
            scanf("%lf,%lf", &a, &b);

            p[i].real(a);
            p[i].imag(b);
        }

        int max = 1;
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                if(std::abs(std::abs(p[j] - p[i]) - 2.0) < EPS){
                    P c = (p[i] + p[j]) / 2.0;

                    int cnt = 2;
                    for(int k = 0; k < n; k++){
                        if(k == i || k == j) continue;

                        if(std::abs(p[k] - c) - 1.0 < EPS){ cnt++; }
                    }
                    if(cnt > max) max = cnt;
                }else if(std::abs(p[j] - p[i]) < 2.0){
                    P xx = p[j] - p[i];
                    P ce = p[i] + (xx / 2.0);
                    P no1 = (ce * P(0, 1)) / std::abs(ce);
                    P no2 = (ce * P(0,-1)) / std::abs(ce);
                    double dis = sqrt(1 - pow(std::abs(xx) / 2.0, 2));
                    P c = ce + no1 * dis;
                    P q = ce + no2 * dis;

                    int cnt1 = 2, cnt2 = 2;
                    for(int k = 0; k < n; k++){
                        if(k == i || k == j) continue;

                        if(std::abs(p[k] - c) - 1.0 < EPS){ cnt1++; }
                        if(std::abs(p[k] - q) - 1.0 < EPS){ cnt2++; }
                    }
                    if(cnt1 > max) max = cnt1;
                    if(cnt2 > max) max = cnt2;
                }
            }
        }

        printf("%d\n", max);
    }

    return 0;
}