using System.Collections.Generic;
public static void Main()
var testInput = new[] { new TestInput("111222", 2),
new TestInput("1002345", 6),
new TestInput("000000", 1)};
foreach( var item in testInput )
var actual = GetDigitCount(item.Input);
Console.WriteLine($"{item.Input,10} | {actual,2} | expected: {item.Expected}");
public static int GetDigitCount(ReadOnlySpan<char> input)
HashSet<char> hs = new();
foreach(var c in input) if( char.IsDigit(c) ) hs.Add(c) ;
public record struct TestInput(string Input, int Expected);