#include <bits/stdc++.h>
using namespace std;
class Point {
 public:
  double x, y;
  Point(double x = -1, double y = -1) : x(x), y(y) {}
  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  Point operator*(double a) { return Point(a * x, a * y); }
  Point operator/(double a) { return Point(x / a, y / a); }
  bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const Point& p) const {
    return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10);
  }
};
struct Segment {
  Point p1, p2;
  Segment(Point p1 = Point(-1, -1), Point p2 = Point(-1, -1))
      : p1(p1), p2(p2) {}
};
struct Circle {
  Point p;
  double r;
  Circle(Point p = Point(0, 0), double r = 0) : p(p), r(r) {}
  bool operator<(const Circle& a) const {
    if (p.x != a.p.x) return p.x < a.p.x;
    if (p.y != a.p.y) return p.y < a.p.y;
    return r < a.r;
  }
};
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
double norm(Point a) { return a.x * a.x + a.y * a.y; }
int ccw(Point p0, Point p1, Point p2) {
  Point a = p1 - p0;
  Point b = p2 - p0;
  if (cross(a, b) > 0) return 1;
  if (cross(a, b) < 0) return -1;
  if (dot(a, b) < 0) return 2;
  if (norm(a) < norm(b)) return -2;
  return 0;
}
bool isIntersectCC(Circle a, Circle b) {
  double d = sqrt(norm(a.p - b.p));
  double r1 = max(a.r, b.r);
  double r2 = min(a.r, b.r);
  if (d > r1 + r2) return false;
  if (d < r1 - r2) return false;
  return true;
}
pair<Point, Point> getPointsCC(Circle a, Circle b) {
  complex<double> c1, c2;
  c1 = complex<double>(a.p.x, a.p.y);
  c2 = complex<double>(b.p.x, b.p.y);
  double r1 = a.r;
  double r2 = b.r;
  complex<double> A = conj(c2 - c1),
                  B = (r2 * r2 - r1 * r1 - (c2 - c1) * conj(c2 - c1)),
                  C = r1 * r1 * (c2 - c1);
  complex<double> D = B * B - 4.0 * A * C;
  complex<double> z1 = (-B + sqrt(D)) / (2.0 * A) + c1,
                  z2 = (-B - sqrt(D)) / (2.0 * A) + c1;
  Point R1, R2;
  R1 = Point(z1.real(), z1.imag());
  R2 = Point(z2.real(), z2.imag());
  return pair<Point, Point>(R1, R2);
}
int main() {
  int n;
  while (cin >> n, n) {
    vector<Circle> c(n);
    for (int i = 0; i < n; i++) {
      scanf("%lf,%lf", &c[i].p.x, &c[i].p.y);
      c[i].r = 1.0;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (!isIntersectCC(c[i], c[j])) continue;
        pair<Point, Point> pp = getPointsCC(c[i], c[j]);
        int cnt = 0;
        Point p1 = pp.first;
        Point p2 = pp.second;
        for (int k = 0; k < n; k++)
          if (sqrt(norm(p1 - c[k].p)) < (1e-10) + 1.0) cnt++;
        ans = (ans < cnt ? cnt : ans);
        cnt = 0;
        for (int k = 0; k < n; k++)
          if (sqrt(norm(p2 - c[k].p)) < (1e-10) + 1.0) cnt++;
        ans = (ans < cnt ? cnt : ans);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
