#include <bits/stdc++.h>
using namespace std;
int N;
complex<double> in[102];
vector<complex<double> > getCross(int i, int j) {
  double dist = abs(in[i] - in[j]);
  if (dist > 2.0) {
    return vector<complex<double> >();
  }
  complex<double> ij = in[j] - in[i];
  double ijAbs = abs(ij);
  complex<double> ijN0 = (ij * complex<double>(0, 1)) / ijAbs;
  complex<double> ijN1 = (ij * complex<double>(0, -1)) / ijAbs;
  complex<double> ijHalf = in[i] + complex<double>(ij.real() / 2, ij.imag());
  double height = 1 - pow(ijAbs / 2, 2);
  complex<double> p0 = ijHalf + ijN0 * height;
  complex<double> p1 = ijHalf + ijN1 * height;
  vector<complex<double> > ret;
  ret.push_back(p0);
  ret.push_back(p1);
  return ret;
}
int main() {
  while (cin >> N, N) {
    for (int(i) = 0; (i) < (int)(N); ++(i)) {
      double x, y;
      char camma;
      cin >> x >> camma >> y;
      in[i] = complex<double>(x, y);
    }
    int ans = 1;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        vector<complex<double> > cross = getCross(i, j);
        if (cross.size() == 0) continue;
        for (int k = 0; k < 2; k++) {
          complex<double> cur = cross[k];
          int cnt = 2;
          for (int l = 0; l < N; l++) {
            if (l == i || l == j) continue;
            double dist = abs(cur - in[l]);
            if (dist < 1.0) {
              ++cnt;
            }
          }
          if (ans < cnt) {
            ans = cnt;
          }
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
