from typing import Union
from pathlib import Path
import re


def first(filename: Union[str, Path]) -> int:
    """
    In each group of letters (separated by a double newline), return
    the number of distinct letters.
    """
    with open(filename, "rt") as infile:
        groups = infile.read().strip().split("\n\n")

    return sum(len(set(re.sub(r"\s", "", group))) for group in groups)