#include <bits/stdc++.h>
using namespace std;
int n, ans;
double x[101], y[101], a[101][101];
int vis[101], cur[101];
void dfs(int x, int p) {
  if (vis[x] < cur[x]) return;
  cur[x] = p;
  for (int i = x - 1; i >= 0; i--)
    if (a[x][i] <= 2) dfs(i, p + 1);
  ans = max(ans, p);
}
int main() {
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) scanf("%lf,%lf", &x[i], &y[i]);
    memset(a, 0, sizeof(a));
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
        a[i][j] = a[j][i] =
            sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
    ans = 0;
    memset(vis, 0, sizeof(vis));
    for (int i = n - 1; i >= 0; i--) {
      memset(cur, 0, sizeof(cur));
      dfs(i, 1);
      for (int i = 0; i < n; i++) vis[i] = max(vis[i], cur[i]);
    }
    cout << ans << endl;
  }
}
