#include <bits/stdc++.h>
using namespace std;
struct Circle {
  complex<double> center;
  double r;
  pair<complex<double>, complex<double> > 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 complex<double> e = (c.center - center) / d;
    return make_pair(center + e * complex<double>(cos_, sin_),
                     center + e * complex<double>(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 = complex<double>(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<complex<double>, complex<double> > 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;
      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;
        double D = pow(b / 2, 2) - cv;
        if (fabs(D) < 1e-8) D = 0;
        const double sr = sqrt(D);
        eventx.push_back(make_pair(b / 2 - sr, 1));
        eventx.push_back(make_pair(b / 2 + sr, -1));
      }
      sort(eventx.begin(), eventx.end());
      int cnt = 0;
      for (vector<pair<double, int> >::iterator it = eventx.begin();
           it != eventx.end(); ++it) {
        cnt += it->second;
        ans = max(ans, cnt);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
