#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef pair<P, double> C;
struct L {
  P p, q;
  L(P p, P q) : p(p), q(q) {}
};
const double EPS = 1e-13;
namespace std {
bool operator<(const P &a, const P &b) {
  return make_pair(real(a), imag(a)) < make_pair(real(b), imag(b));
}
}  // namespace std
bool crossCircle(C c1, C c2) {
  double r1 = c1.second;
  double r2 = c2.second;
  double d = abs(c1.first - c2.first);
  if (d < r1 || d < r2) return d - abs(r1 - r2) > EPS;
  return r1 + r2 - d > -EPS;
}
pair<P, P> crossPoint(C c1, C c2) {
  double r1 = c1.second;
  double r2 = c2.second;
  double r3 = abs(c1.first - c2.first);
  double rc = (r3 * r3 + r1 * r1 - r2 * r2) / (2 * r3);
  double rs = sqrt(r1 * r1 - rc * rc);
  P dif = (c2.first - c1.first) / r3;
  P p1 = c1.first + dif * P(rc, rs);
  P p2 = c1.first + dif * P(rc, -rs);
  return make_pair(p1, p2);
}
int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    vector<P> all;
    for (int i = 0; i < n; i++) {
      string temp;
      cin >> temp;
      double x = atof(temp.substr(0, temp.find(',')).c_str());
      double y = atof(temp.substr(temp.find(',') + 1).c_str());
      all.push_back(P(x, y));
    }
    int N = int((all).size());
    vector<P> ten;
    for (int i = 0; i < N - 1; i++) {
      for (int j = i + 1; j <= N - 1; j++) {
        C c1 = make_pair(all[i], 1.0);
        C c2 = make_pair(all[j], 1.0);
        if (crossCircle(c1, c2)) {
          pair<P, P> temp;
          temp = crossPoint(c1, c2);
          ten.push_back(temp.first);
          ten.push_back(temp.second);
        }
      }
    }
    int ans = 0;
    for (int k = 0; k < int((ten).size()); k++) {
      int count = 0;
      for (int i = 0; i < N; i++) {
        if (abs(all[i] - ten[k]) <= 1.0) {
          count++;
        }
      }
      ans = max(ans, count);
    }
    cout << ans << endl;
  }
  return 0;
}
