#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>
#include <deque>
#include <set>
#include <climits>
#include <complex>

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)

using namespace std;

typedef long long int lint;
typedef complex<double> P, point;
template<typename T> inline bool in(T& x){ return cin >> x; }
template<typename T> inline T in(){T x; cin >> x; return x; }

const double EPS = 1e-7;

pair<P, P> cci(const P& a, const P& b){
    P d=b-a;
    P A=conj(d), B=-d*A, C=d;
    P D=B*B-4.0*A*C;
    P z1=(-B+sqrt(D))/(2.0*A)+a, z2=(-B-sqrt(D))/(2.0*A)+a;
    return make_pair(z1, z2);
}

int get_max_overlaps(const vector<vector<int> >& graph, const vector<P> seals, int v)
{
    int maxi = 1;

    rep(i, graph[v].size()){
        int x = graph[v][i];
        pair<P, P> cp = cci(seals[v], seals[x]);
        int fc, sc;
        fc = sc = 2;
        rep(j, graph[v].size()){
            int y = graph[v][j];
            if (y == x) continue;
            if (abs(cp.first - seals[y]) <= 1.0 + EPS) fc++;
            if (abs(cp.second - seals[y]) <= 1.0 + EPS) sc++;
        }
        maxi = max(maxi, max(fc, sc));
    }
    return maxi;
}

int main()
{
    int n;
    while (in(n), n){
        vector<P> seals;
        rep(i, n){
            double x, y;
            scanf("%lf,%lf", &x, &y);
            seals.push_back(P(x, y));
        }
        vector<vector<int> > graph;
        rep(i, n){
            vector<int> edges;
            rep(j, n){
                if (i == j) continue;
                if (abs(seals[i] - seals[j]) < 2.0 + EPS){
                    edges.push_back(j);
                }
            }
            graph.push_back(edges);
        }
        int maxi = 1;
        rep(i, graph.size()){
            if (maxi <= graph[i].size()){
                maxi = max(maxi, get_max_overlaps(graph, seals, i));
            }
        }
        printf("%d\n", maxi);
    }

	return (0);
}