#include <bits/stdc++.h>
using namespace std;
int n;
bool used[100];
vector<complex<double>> seals(100);
bool overlap(complex<double> &a, complex<double> &b, double dist) {
  if (norm(a - b) <= dist) return true;
  return false;
}
int solve(complex<double> &i1, complex<double> &i2) {
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      bool ok = true;
      for (int j = 0; j < n; ++j) {
        if (used[j] && !overlap(seals[i], seals[j], 4.0) &&
            !overlap(seals[i], i1, 1.0) && !overlap(seals[i], i2, 1.0)) {
          ok = false;
          break;
        }
      }
      if (ok) {
        used[i] = true;
        ret = max(ret, 1 + solve(i1, i2));
        used[i] = false;
      }
    }
  }
  return ret;
}
int main() {
  while (cin >> n, n) {
    memset(used, 0, sizeof used);
    seals.clear();
    double x, y;
    char c;
    for (int i = 0; i < n; ++i) {
      cin >> x >> c >> y;
      seals[i].real(x);
      seals[i].imag(y);
    }
    int ret = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        if (overlap(seals[i], seals[j], 4.0)) {
          ret = max(ret, 2);
          complex<double> m = (seals[i] + seals[j]) / 4.0;
          double k = sqrt(1.0 - norm(m - seals[j])) / sqrt(norm(m - seals[j]));
          double dx = (m.imag() - seals[j].imag()) * k;
          double dy = (seals[j].real() - m.real()) * k;
          complex<double> intersect1(m.real() + dx, m.imag() + dy);
          complex<double> intersect2(m.real() - dx, m.imag() - dy);
          used[i] = used[j] = true;
          ret = max(ret, 2 + solve(intersect1, intersect2));
          used[i] = used[j] = false;
        }
      }
    }
    cout << ret << endl;
  }
  return 0;
}
