#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    vector<complex<double> > vp;
    for (int i = (0); i < (n); i++) {
      complex<double> p;
      double a, b;
      char g;
      cin >> a >> g >> b;
      p.real(a);
      p.imag(b);
      vp.push_back(p);
    }
    int ans = 1;
    for (int i = (0); i < (vp.size()); i++) {
      int sum = 1;
      for (int j = (0); j < (vp.size()); j++) {
        if (i == j) continue;
        if (abs(vp[i] - vp[j]) <= 2) sum++;
      }
      ans = max(ans, sum);
    }
    cout << ans << endl;
  }
}
