#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

template <typename Tlist, typename Tfunc>
void __combination(
        Tlist const& list, typename Tlist::size_type const n, Tfunc const& func,
        Tlist& tmp, typename Tlist::size_type const i, typename Tlist::size_type const j)
{
    if (i == n)
    {
        func(tmp);
        return;
    }

    for (typename Tlist::size_type k = j; k != list.size() + (1 + i- n); ++k)
    {
        tmp[i] = list[k];
        __combination(list, n, func, tmp, i + 1, k + 1);
    }
}

template <typename Tlist, typename Tfunc>
void combination(
        Tlist const& list, typename Tlist::size_type const n, Tfunc const& func)
{
    Tlist tmp(n);
    __combination(list, n, func, tmp, 0, 0);
}

struct Point {
    double x;
    double y;
};

vector<Point> points;

inline double distance_2(Point p1, Point p2) {
    double d2 = (p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y);
    return d2;
}

struct Overlap{
    vector<char> idxs;
    Point center;
};

vector<char> indexes;

deque<Overlap> overlaps;

int search_count_tmp = 2;

void search_overlap(int rest) {
    if(rest == 0 || overlaps.size() == 0) return;
    deque<Overlap> next_overlaps;

    while(!overlaps.empty()) {
        Overlap o = overlaps.front();
        double x = 0;
        double y = 0;
        for(char index : o.idxs) {
            x += points[index].x;
            y += points[index].y;
        }

        // for new points
        for (char i = 0; i < points.size(); ++i) {
            if(find(o.idxs.begin(), o.idxs.end(), i) == o.idxs.end()) { // not select
                Point next_p = points[i];
                if(distance_2(o.center, next_p)  > 2.0 + 1e-9) continue; // too far max 2.0
                double c_x = x + next_p.x;
                double c_y = y + next_p.y;
                int current_count = o.idxs.size();

                // calc next_center
                c_x = c_x / (current_count + 1);
                c_y= c_y / (current_count + 1);

                // count in circle
                int next_count = 0;
                double d2 = distance_2(Point{c_x, c_y}, next_p);
                if(d2 <= 1.0 + 1e-9) next_count++;
                for (int index : o.idxs) {
                    double d2 = distance_2(Point{c_x, c_y}, points[index]);
                    if(d2 <= 1.0 + 1e-9) next_count++;
                }

                if (next_count > current_count) { // if new overlap
                    search_count_tmp = next_count;
                    Overlap next_o;
                    next_o.idxs.push_back(i);
                    for (char index : o.idxs) {
                        next_o.idxs.push_back(index);
                    }
                    next_o.center = Point{c_x, c_y};
                    next_overlaps.push_back(next_o);
                }
            }
        }

        // next overlap
        overlaps.pop_front();
    }

    // memory clear
    overlaps.clear();
    overlaps.shrink_to_fit();

    // next dispatch
    overlaps = next_overlaps;
    search_overlap(rest - 1);
}

int main() {
    int n;
    while (cin >> n) {
        if(n == 0) break;
        points.clear();
        points.shrink_to_fit();
        indexes.clear();
        indexes.shrink_to_fit();
        overlaps.clear();
        overlaps.shrink_to_fit();
        search_count_tmp = 1;

        // load points and idxs
        for (char i = 0; i < n; ++i) {
            Point p;
            scanf("%lf,%lf",&p.x,&p.y);
            points.push_back(p);
            indexes.push_back(i);
            Overlap o;
            o.idxs.push_back(i);
            overlaps.push_back(o);
        }

        // load all 2 points overlaps
        combination(
                indexes, 2, [](vector<char> const& a) {
                    vector<char> index_pair;
                    for (auto i(a.begin()); i != a.end();  ++i) {
                        index_pair.push_back(*i);
                    }
                    Point p1 = points[index_pair[0]];
                    Point p2 =  points[index_pair[1]];
                    double d2 = distance_2(p1, p2);
                    if(d2 <= 1.0 + 1e-9) {
                        Overlap o;
                        o.idxs.push_back(index_pair[0]);
                        o.idxs.push_back(index_pair[1]);
                        o.center = Point{ (p1.x + p2.x) / 2 , (p1.y + p2.y) / 2};
                        overlaps.push_back(o);
                    };
                });

        // two point 0 is 0
        if (overlaps.size() == 0) {
            cout << 0 << endl;
        } else {
            search_overlap(n - 2);
            cout << search_count_tmp << endl;
        }
    }

    return 0;
}