#include <bits/stdc++.h>
using namespace std;
template <typename Tlist, typename Tfunc>
void __combination(Tlist const& list, typename Tlist::size_type const n,
                   Tfunc const& func, Tlist& tmp,
                   typename Tlist::size_type const i,
                   typename Tlist::size_type const j) {
  if (i == n) {
    func(tmp);
    return;
  }
  for (typename Tlist::size_type k = j; k != list.size() + (1 + i - n); ++k) {
    tmp[i] = list[k];
    __combination(list, n, func, tmp, i + 1, k + 1);
  }
}
template <typename Tlist, typename Tfunc>
void combination(Tlist const& list, typename Tlist::size_type const n,
                 Tfunc const& func) {
  Tlist tmp(n);
  __combination(list, n, func, tmp, 0, 0);
}
struct Point {
  double x;
  double y;
};
vector<Point> points;
double distance_2(Point p1, Point p2) {
  double d2 = (p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y);
  return d2;
}
struct Overlap {
  vector<int> indexes;
};
vector<int> indexes;
queue<Overlap> overlaps;
int search_count_tmp = 2;
void search_overlap(int rest) {
  if (rest == 0 || overlaps.size() == 0) return;
  queue<Overlap> next_overlaps;
  while (!overlaps.empty()) {
    Overlap o = overlaps.front();
    vector<int> v = o.indexes;
    double x = 0;
    double y = 0;
    for (int index : v) {
      x += points[index].x;
      y += points[index].y;
    }
    for (int i = 0; i < points.size(); ++i) {
      if (find(v.begin(), v.end(), i) == v.end()) {
        double c_x = x + points[i].x;
        double c_y = y + points[i].y;
        int current_count = v.size();
        c_x = c_x / (current_count + 1);
        c_y = c_y / (current_count + 1);
        int next_count = 0;
        double d2 = distance_2(Point{c_x, c_y}, points[i]);
        if (d2 <= 1.0 + 1e-9) next_count++;
        for (int index : v) {
          double d2 = distance_2(Point{c_x, c_y}, points[index]);
          if (d2 <= 1.0 + 1e-9) next_count++;
        }
        if (next_count > current_count) {
          search_count_tmp = next_count;
          Overlap next_o;
          next_o.indexes.push_back(i);
          for (int index : v) {
            next_o.indexes.push_back(index);
          }
          next_overlaps.push(next_o);
        }
      }
    }
    overlaps.pop();
  }
  overlaps = next_overlaps;
  search_overlap(rest - 1);
}
int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    vector<Point> new_points;
    points = new_points;
    vector<int> new_indexes;
    indexes = new_indexes;
    queue<Overlap> new_overlaps;
    overlaps = new_overlaps;
    search_count_tmp = 2;
    for (int i = 0; i < n; ++i) {
      Point p;
      scanf("%lf,%lf", &p.x, &p.y);
      points.push_back(p);
      indexes.push_back(i);
    }
    combination(indexes, 2, [](vector<int> const& a) {
      vector<int> index_pair;
      for (auto i(a.begin()); i != a.end(); ++i) {
        index_pair.push_back(*i);
      }
      double d2 = distance_2(points[index_pair[0]], points[index_pair[1]]);
      if (d2 <= 1.0 + 1e-9) {
        Overlap o;
        o.indexes.push_back(index_pair[0]);
        o.indexes.push_back(index_pair[1]);
        overlaps.push(o);
      };
    });
    if (overlaps.size() == 0) {
      cout << 0 << endl;
    } else {
      search_overlap(n - 2);
      cout << search_count_tmp << endl;
    }
  }
  return 0;
}
