#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

typedef complex<double> Vector;

struct Circle {
    Vector center;
    double r;

    pair<Vector,Vector> intersection(const Circle &c) const {
        const double d = abs(c.center - center);
        const double cos_ = (d*d + r*r - c.r*c.r) / (2*d);
        const double sin_ = sqrt(r*r - cos_*cos_);
        const Vector e = (c.center - center) / d;
        return make_pair(center + e*Vector(cos_, sin_), center + e*Vector(cos_, -sin_));
    }

    inline bool intersects(const Circle &c) const {
        return norm(center-c.center) <= pow(r+c.r, 2);
    }

    inline bool contains(const Circle &c) const {
        return abs(center-c.center)+c.r <= r;
    }
};

int main() {
    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        vector<Circle> circles(N);
        for(int i = 0; i < N; ++i) {
            double x, y;
            scanf("%lf,%lf", &x, &y);
            circles[i].center = Vector(x, y);
            circles[i].r = 1;
        }
        vector<double> events;
        for(int i = 0; i < N; ++i) {
            const Circle c1 = circles[i];
            events.push_back(c1.center.imag() - c1.r);
            events.push_back(c1.center.imag() + c1.r);
            for(int j = 0; j < i; ++j) {
                const Circle c2 = circles[j];
                if(c1.contains(c2) || c2.contains(c1)) continue;
                if(!c1.intersects(c2)) continue;
                pair<Vector,Vector> vs = c1.intersection(c2);
                events.push_back(vs.first.imag());
                events.push_back(vs.second.imag());
            }
        }
        sort(events.begin(), events.end());
        events.erase(unique(events.begin(), events.end()), events.end());
        int ans = 0;
        for(vector<double>::const_iterator it = events.begin(); it != events.end(); ++it) {
            const double y = *it;
            //cout << "y " << y << endl;
            vector<pair<double, int> > eventx;
            for(int i = 0; i < N; ++i) {
                const Circle c = circles[i];
                if(fabs(c.center.imag() - y) > c.r) continue;
                const double b = 2 * c.center.real();
                const double cv = y*y - 2*c.center.imag()*y + norm(c.center) - c.r*c.r;
                const double sr = sqrt(pow(b/2, 2) - cv);
                eventx.push_back(make_pair(b/2 - sr, 1));
                //cout << eventx.back().first << ' ';
                eventx.push_back(make_pair(b/2 + sr, -1));
                //cout << eventx.back().first << ' ' << endl;
            }
            sort(eventx.begin(), eventx.end());
            int cnt = 0;
            for(vector<pair<double,int> >::iterator it = eventx.begin(); it != eventx.end(); ++it) {
                //cout << it->second << endl;
                cnt += it->second;
                ans = max(ans, cnt);
            }
        }
        cout << ans << endl;
    }
    return 0;
}