#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-8;
int n;
int dfs(int searched, vector<int> seal, vector<set<int> > &over) {
  int newseal = -1;
  for (int i = (searched); i < (int)(n); ++i) {
    if (find(seal.begin(), seal.end(), i) != seal.end()) continue;
    bool ok = true;
    for (int j = (0); j < (int)(seal.size()); ++j) {
      if (over[seal[j]].find(i) == over[seal[j]].end()) {
        ok = false;
        break;
      }
    }
    if (ok) {
      newseal = i;
      break;
    }
  }
  int ret;
  if (newseal == -1) {
    ret = seal.size();
  } else {
    vector<int> nextseal = seal;
    nextseal.push_back(newseal);
    ret = dfs(newseal + 1, nextseal, over);
    ret = max(ret, dfs(newseal + 1, seal, over));
  }
  return ret;
}
int main(void) {
  while (cin >> n) {
    if (n == 0) break;
    double x[100], y[100];
    vector<set<int> > overlap(n);
    for (int i = (0); i < (int)(n); ++i) {
      scanf("%lf,%lf", x + i, y + i);
    }
    for (int i = (0); i < (int)(n); ++i)
      for (int j = (i + 1); j < (int)(n); ++j) {
        double dist =
            sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]));
        if (dist <= 2) {
          overlap[i].insert(j);
          overlap[j].insert(i);
        }
      }
    int ans = 0;
    for (int i = (0); i < (int)(n); ++i)
      ans = max(ans, dfs(0, vector<int>(1, i), overlap));
    cout << ans << endl;
  }
  return 0;
}
