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

namespace ConsoleApplication1
{
    class Program
    {
        static readonly double EPS = 1E-10;

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                Circle[] circles = new Circle[n];

                for (int i = 0; i < n; i++)
                {
                    string[] input = Console.ReadLine().Split(',');
                    double x = double.Parse(input[0]);
                    double y = double.Parse(input[1]);

                    circles[i] = new Circle(new Point(x, y), 1.0);
                }

                int ans = 1;

                for (int i = 0; i < n; i++)
                {
                    for (int j = i + 1; j < n; j++)
                    {
                        List<Point> v = GetCrossPointsCC(circles[i], circles[j]);

                        if (v.Count == 0) continue;

                        int countA = 2;
                        int countB = 2;

                        for (int k = 0; k < n; k++)
                        {
                            if (i == k || j == k) continue;

                            if ((v[0] - circles[k].p).Abs - 1.0 < EPS) countA++;

                            if (v.Count != 2) continue;

                            if ((v[1] - circles[k].p).Abs - 1.0 < EPS) countB++;
                        }
                        ans = Math.Max(ans, countA);
                        ans = Math.Max(ans, countB);
                    }
                }
                sb.AppendLine(ans.ToString());
            }
            Console.Write(sb);
        }

        static List<Point> GetCrossPointsCC(Circle c1, Circle c2)
        {
            List<Point> ret = new List<Point>();

            Point ab = c2.p - c1.p;
            double d = ab.Abs;
            double crL = (ab.Norm + c1.r * c1.r - c2.r * c2.r) / (2 * d);

            if (EQ(d, 0) || c1.r < Math.Abs(crL)) return ret;

            Point abN = ab * new Point(0.0, Math.Sqrt(c1.r * c1.r - crL * crL) / d);
            Point cp = c1.p + ab * (crL / d);
            ret.Add(cp + abN);

            if (!EQ(abN.Norm, 0)) ret.Add(cp - abN);

            return ret;
        }

        static bool EQ(double n, double m) { return Math.Abs(n - m) < EPS; }
    }

    class Point : IComparable
    {
        static readonly double EPS = 1E-10;

        internal double x, y;

        public Point(double x, double y)
        {
            this.x = x;
            this.y = y;
        }

        public double Abs { get { return Math.Sqrt(Norm); } }
        public double Norm { get { return x * x + y * y; } }

        public double Dot(Point p) { return x * p.x + y * p.y; }
        public double Cross(Point p) { return x * p.y - y * p.x; }
        public double Distance(Point p) { return (this - p).Abs; }

        public static Point operator +(Point a, Point b) { return new Point(a.x + b.x, a.y + b.y); }
        public static Point operator -(Point a, Point b) { return new Point(a.x - b.x, a.y - b.y); }
        public static Point operator *(Point a, Point b) { return new Point(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }
        public static Point operator *(Point p, double d) { return new Point(p.x * d, p.y * d); }
        public static Point operator /(Point p, double d) { return new Point(p.x / d, p.y / d); }
        public static bool operator <(Point a, Point b) { return Math.Abs(a.x - b.x) > EPS ? a.x < b.x : a.y < b.y; }
        public static bool operator >(Point a, Point b) { return Math.Abs(a.x - b.x) > EPS ? a.x > b.x : a.y > b.y; }
        public static bool operator ==(Point a, Point b) { return Math.Abs(a.x - b.x) < EPS && Math.Abs(a.y - b.y) < EPS; }
        public static bool operator !=(Point a, Point b) { return Math.Abs(a.x - b.x) >= EPS || Math.Abs(a.y - b.y) >= EPS; }

        public int CompareTo(object obj)
        {
            var other = obj as Point;
            if (obj == null) return -1;

            ComparerX compX = new ComparerX();
            return compX.Compare(this, other);
        }

        public override bool Equals(object obj)
        {
            var other = obj as Point;
            return Math.Abs(x - other.x) < EPS && Math.Abs(y - other.y) < EPS;
        }

        public override int GetHashCode()
        {
            return x.GetHashCode() ^ y.GetHashCode();
        }

        public override string ToString()
        {
            return string.Format("{0:f10} {1:f10}", x, y);
        }
    }

    class ComparerX : IComparer<Point>
    {
        static readonly double EPS = 1E-10;

        public int Compare(Point a, Point b)
        {
            if (a.x - b.x < -EPS) return -1;
            if (a.x - b.x > EPS) return 1;
            if (a.y - b.y < -EPS) return -1;
            if (a.y - b.y > EPS) return 1;
            return 0;
        }
    }

    class ComparerY : IComparer<Point>
    {
        static readonly double EPS = 1E-10;

        public int Compare(Point a, Point b)
        {
            if (a.y - b.y < -EPS) return -1;
            if (a.y - b.y > EPS) return 1;
            if (a.x - b.x < -EPS) return -1;
            if (a.x - b.x > EPS) return 1;
            return 0;
        }
    }

    class Segment
    {
        internal Point p1, p2;

        public Segment(Point p1, Point p2)
        {
            this.p1 = p1;
            this.p2 = p2;
        }
    }

    class Circle
    {
        internal Point p;
        internal double r;

        public Circle(Point p, double r)
        {
            this.p = p;
            this.r = r;
        }
    }
}

Measured memory_bytes: 9464