#include <bits/stdc++.h>
using namespace std;
template <class _T>
_T MAX(_T p1, _T p2) {
  return (p1 > p2) ? p1 : p2;
}
template <class _T>
_T MIN(_T p1, _T p2) {
  return (p1 < p2) ? p1 : p2;
}
bool check(complex<double> p1, complex<double> p2) {
  return (abs(p1 - p2) <= 2);
}
void solve(vector<complex<double> > &v) {
  int n = v.size();
  deque<set<int> > qsi;
  for (int i = (0); i < (0 + n); ++i) {
    complex<double> &p = v[i];
    for (__typeof__((qsi).begin()) it = (qsi).begin(); it != (qsi).end();
         ++it) {
      bool flag = true;
      for (__typeof__((*it).begin()) it2 = (*it).begin(); it2 != (*it).end();
           ++it2) {
        if (!check(v[*it2], p)) {
          flag = false;
          break;
        }
      }
      if (flag) {
        (*it).insert(i);
      }
    }
    set<int> si;
    si.insert(i);
    qsi.push_back(si);
    ;
    for (__typeof__((qsi).begin()) it = (qsi).begin(); it != (qsi).end();
         ++it) {
      ;
    }
  }
  int max = 0;
  for (__typeof__((qsi).begin()) it = (qsi).begin(); it != (qsi).end(); ++it) {
    int num = it->size();
    max = MAX(max, num);
  }
  cout << max << endl;
  return;
}
int main() {
  int n;
  double x, y;
  char c;
  while (cin >> n, n) {
    vector<complex<double> > v;
    for (int i = (0); i < (0 + n); ++i) {
      cin >> x >> c >> y;
      v.push_back(complex<double>(x, y));
    }
    solve(v);
  }
  return 0;
}
