using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Miscelleneous {
   struct Point {
      public double x { get; set; }
      public double y { get; set; }
      public double Norm() { return x*x+y*y; }
      public static Point operator -(Point a,Point b) { return new Point { x=a.x-b.x,y=a.y-b.y }; }
   }
   struct V{ public int x { get; set; } public int y { get; set; } }
   class Program {
      static int cin() { return int.Parse(Console.ReadLine()); }
      static double[] cins() { 
         string[] ss = Console.ReadLine().Split(',');
         double[] Res = new double[ss.Length];
         for (int i = 0; i<ss.Length; i++) Res[i]=double.Parse(ss[i]);
         return Res;
      }
      static void Main(string[] args) {
         int n;   double[] se;   Point P; int[] Grv;
         List<Point> Seals = new List<Point>();
         List<V> Edge = new List<V>();
         List<V> G;

         while (true) {
            n=cin();
            if (n==0) return;
            for (int a = 0; a<n; a++) {
               se=cins();
               P=new Point { x=se[0],y=se[1] };
               G=Seals.Select((k,j) => intersects(k,P) ? j : -1)
                  .Where(k => k!=-1).Select(k => new V { x=k,y=a }).ToList();
               Edge=Edge.Union(G).ToList();
               Seals.Add(P);
            }
            Grv=new int[n];
            for (int i = 0; i<n; i++)
               Grv[i]=Edge.Where(k => k.x==i||k.y==i).Count()+1;
            Console.WriteLine(Grv.Max());
            Seals.Clear(); Edge.Clear();
         }
      }

      static bool intersects(Point a,Point b) { return (a-b).Norm()<=4; }

   }
}