count = 0 for i in range(10000): # Start from 100 num_str = str(i).zfill(4) # fill with zeros if len(set(num_str)) == 3: count += 1 print(f"Total numbers with three different digits: {count}")