#include <bits/stdc++.h>
using namespace std;
class Point {
 private:
  double x_;
  double y_;

 public:
  Point() : x_(0), y_(0) {}
  explicit Point(double x, double y) : x_(x), y_(y) {}
  explicit Point(double x1, double y1, double x2, double y2)
      : x_(x2 - x1), y_(y2 - y1) {}
  double x() { return x_; }
  double y() { return y_; }
  double x() const { return x_; }
  double y() const { return y_; }
  Point& operator+=(const Point& p) {
    x_ += p.x_;
    y_ += p.y_;
    return *this;
  }
  Point& operator-=(const Point& p) {
    x_ -= p.x_;
    y_ -= p.y_;
    return *this;
  }
  Point& operator*=(double s) {
    x_ *= s;
    y_ *= s;
    return *this;
  }
  Point& operator/=(double s) {
    x_ /= s;
    y_ /= s;
    return *this;
  }
  friend bool operator==(const Point& p1, const Point& p2) {
    return p1.x_ == p2.x_ && p1.y_ == p2.y_;
  }
  friend bool operator!=(const Point& p1, const Point& p2) {
    return !(p1 == p2);
  }
  friend Point operator+(const Point& p1, const Point& p2) {
    return Point(p1.x_ + p2.x_, p1.y_ + p2.y_);
  }
  friend Point operator-(const Point& p1, const Point& p2) {
    return Point(p1.x_ - p2.x_, p1.y_ - p2.y_);
  }
  friend Point operator*(const Point& p, double s) {
    return Point(p.x_ * s, p.y_ * s);
  }
  friend Point operator/(const Point& p, double s) {
    return Point(p.x_ / s, p.y_ / s);
  }
  friend Point operator*(double s, const Point& p) {
    return Point(p.x_ * s, p.y_ * s);
  }
  double norm() { return x_ * x_ + y_ * y_; }
  double abs() { return sqrt(norm()); }
  double angle() { return atan2(y_, x_); }
};
double norm(const Point& p) { return p.x() * p.x() + p.y() * p.y(); }
double abs(const Point& p) { return sqrt(norm(p)); }
double angle(const Point& p) { return atan2(p.y(), p.x()); }
Point polar(double a, double r) { return Point(cos(a), sin(a)) * r; }
double dist_pow(const Point& p1, const Point& p2) {
  return norm(Point(p2.x() - p1.x(), p2.y() - p1.y()));
}
double distance(const Point& p1, const Point& p2) {
  return abs(Point(p2.x() - p1.x(), p2.y() - p1.y()));
}
class Circle {
 private:
  Point c;
  double r_;

 public:
  Circle() : c(Point(0.0, 0.0)), r_(0.0) {}
  explicit Circle(Point c_, double r_) : c(c_), r_(r_) {}
  explicit Circle(double cx, double cy, double r_) : c(Point(cx, cy)), r_(r_) {}
  double cx() { return c.x(); }
  double cy() { return c.y(); }
  double r() { return r_; }
  double cx() const { return c.x(); }
  double cy() const { return c.y(); }
  double r() const { return r_; }
  Point center() { return c; }
  Point center() const { return c; }
  friend bool operator==(const Circle& c1, const Circle& c2) {
    return c1.c == c2.c && c1.r_ == c2.r_;
  }
  friend bool operator!=(const Circle& c1, const Circle& c2) {
    return c1.c != c2.c || c1.r_ != c2.r_;
  }
};
pair<Point, Point> Cross_Point(const Circle& c1, const Circle& c2) {
  double d, a, t;
  d = abs(c1.center() - c2.center());
  a = acos((c1.r() * c1.r() + d * d - c2.r() * c2.r()) / (2 * c1.r() * d));
  t = angle(c2.center() - c1.center());
  return make_pair(c1.center() + polar(c1.r(), t + a),
                   c1.center() + polar(c1.r(), t - a));
}
int N;
double X, Y;
char ch;
int main() {
  vector<Circle> Plane;
  while (true) {
    cin >> N;
    if (N == 0) {
      break;
    }
    Plane.clear();
    for (int i = 0; i < N; i++) {
      cin >> X >> ch >> Y;
      Plane.push_back(Circle(X, Y, 1));
    }
    int max_ = 1, count = 0;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        count = 1;
        if (dist_pow(Plane[i].center(), Plane[j].center()) < 4 + 0.00000001) {
          Point p1 = Cross_Point(Plane[i], Plane[j]).first;
          Point p2 = Cross_Point(Plane[i], Plane[j]).second;
          count = 2;
          for (int k = 0; k < N; k++) {
            if (k != i && k != j) {
              if (dist_pow(Plane[k].center(), p1) < 1 + 0.00000001) {
                count++;
              }
            }
          }
          max_ = max(count, max_);
          count = 2;
          for (int k = 0; k < N; k++) {
            if (k != i && k != j) {
              if (dist_pow(Plane[k].center(), p2) < 1 + 0.00000001) {
                count++;
              }
            }
          }
        }
        max_ = max(count, max_);
      }
    }
    cout << max_ << endl;
  }
  return 0;
}
