#include <bits/stdc++.h>
using namespace std;
class Point {
 public:
  double x;
  double y;
  Point(double xx, double yy) {
    x = xx;
    y = yy;
  }
  Point() {
    x = 0;
    y = 0;
  }
};
double sqDist(Point p1, Point p2) {
  return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);
}
void intersection(Point &s1, Point &s2, Point &d1, Point &d2) {
  double x1, y1, x2, y2, d, k;
  x1 = s1.x;
  y1 = s1.y;
  x2 = s2.x;
  y2 = s2.y;
  d = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
  k = sqrt((4 - d) / (4 * d));
  d1.x = (x1 + x2) / 2 + k * (y2 - y1);
  d1.y = (y1 + y2) / 2 - k * (x2 - x1);
  d2.x = (x1 + x2) / 2 - k * (y2 - y1);
  d2.y = (y1 + y2) / 2 + k * (x2 - x1);
}
int solve(int n) {
  int ret = 1;
  vector<Point> seals;
  for (int i = 0; i < n; i++) {
    double x, y;
    scanf("%lf,%lf", &x, &y);
    seals.push_back(Point(x, y));
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      double d = sqDist(seals[i], seals[j]);
      if (d > 4) continue;
      int overlap = 2;
      Point is1, is2;
      intersection(seals[i], seals[j], is1, is2);
      for (int k = 0; k < n; k++) {
        if (k == i || k == j) continue;
        if (sqDist(seals[k], is1) <= 1 || sqDist(seals[k], is2) <= 1) {
          overlap++;
        }
      }
      if (overlap > ret) ret = overlap;
    }
  }
  return ret;
}
int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0) break;
    cout << solve(n) << endl;
  }
  return 0;
}
