#!/usr/bin/env python3 import sys import re from collections import defaultdict E = defaultdict(list) # Parse in edges for l in sys.stdin: a, b = l.strip().split('-') E[a].append(b) E[b].append(a) smallre = re.compile('[a-z]+') def issmall(n): return smallre.match(n) paths = 0 P = [] def search(n, path, has_doubled): global paths global P if n == 'end': paths += 1 P.append(path + n) return if issmall(n) and n in path: if has_doubled: return else: has_doubled = True for c in E[n]: if c != 'start': search(c, path + n, has_doubled) search("start", "", False) print(paths)