A = { frozenset({i for i, c in enumerate(B) if c == "#"}) for B in open("input").read().strip().split("\n\n") } L = {a for a in A if 1 in a} U = A - L print(sum(not l & u for l in L for u in U)) # 40ms with cpython # 30ms with codon