#include <bits/stdc++.h>
using namespace std;
bool used[1000];
int n;
vector<complex<double> > v;
bool Cross(complex<double> a, complex<double> b) {
  double dis = abs(a - b);
  return ((abs(dis - 2) < (1e-10)) || dis < 2.0);
}
int dfs(int s) {
  if (used[s]) return 0;
  used[s] = true;
  int maxCnt = 0;
  for (int i = 0; i < v.size(); i++) {
    if (!used[i]) {
      if (Cross(v[s], v[i])) maxCnt = max(maxCnt, dfs(i) + 1);
    }
  }
  return maxCnt;
}
int main() {
  while (cin >> n && n != 0) {
    double x, y;
    for (int i = 0; i < n; i++) {
      char cm;
      cin >> x >> cm >> y;
      v.push_back(complex<double>(x, y));
    }
    fill(used, used + 1000, false);
    int maxCnt = 1;
    for (int i = 0; i < v.size(); i++) {
      if (!used[i]) {
        maxCnt = max(dfs(i) + 1, maxCnt);
      }
    }
    v.clear();
    cout << maxCnt << endl;
  }
  return 0;
}
