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

using namespace std;

const double EPS = 1e-9;
const double INF = 1e10;

struct Point {
    Point(double x, double y) : x(x), y(y) {}
    Point() {}
    double x, y;
};
Point operator+(const Point &a, const Point &b)
{
    return Point(a.x + b.x, a.y + b.y);
}
Point operator-(const Point &a, const Point &b)
{
    return Point(a.x - b.x, a.y - b.y);
}
Point operator*(const Point &a, const double b)
{
    return Point(a.x * b, a.y * b);
}
Point operator*(const Point &a, const Point &b)
{
    return Point(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x);
}
Point operator /(const Point &a, const double b)
{
    return Point(a.x / b, a.y / b);
}
double dot(const Point &a, const Point &b)
{
    return a.x * b.x + a.y * b.y;
}
double norm(const Point &a)
{
    return dot(a, a);
}
double abs(const Point &a)
{
    return sqrt(norm(a));
}
struct Circle : Point {
    double r;
    Circle(Point p = Point(0, 0), double r = 0) : Point(p), r(r) {}
};

// 2円の交点
vector<Point> crosspoint_CC(const Circle &c1, const Circle &c2)
{
    vector<Point> res;
    if (abs(c1 - c2) < EPS)
        return vector<Point> ();
    double d = abs(c1 - c2);
    double rc=(d*d+c1.r*c1.r-c2.r*c2.r)/(2*d);
    double rs=sqrt(c1.r*c1.r-rc*rc);
    Point diff = (c2 - c1)/d;
    res.push_back(Point(c1 + diff * Point(rc,rs)));
    res.push_back(Point(c1 + diff * Point(rc,-rs)));
    return res;
}
// 円が点を含むかどうか (境界含む EPS に注意)
bool is_intersect_CP(const Circle &c, const Point &p){
    return abs(c-p)<=c.r+EPS;
}

int main()
{
    int n;
    char ch;

    while (cin >> n, n) {
        vector<Circle> c(n);
        int ans = 0;

        for (int i = 0; i < n; i++) {
            cin >> c[i].x >> ch >> c[i].y;
            c[i].r = 1.0;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j)
                    continue;
                vector<Point> tmp = crosspoint_CC(c[i], c[j]);

                for (int k = 0; k < tmp.size(); k++) {
                    int cnt = 0;
                    for (int l = 0; l < n; l++) {
                        if (l == i || l == j)
                            continue;
                        if (is_intersect_CP(c[l], tmp[k]))
                            cnt++;
                    }
                    ans = max(ans, cnt);
                }
            }
        }
        if (ans == 0)
            cout << ans << endl;
        else
            cout << ans + 2 << endl;
    }
    return 0;
}