D = int(input()) C1 = input() C2 = input() days = 'x'*D+C1+C2+'x'*D ans = 0 for d in range(D+1): for i in range(len(days)-d+1): if days[i:i+D]!='x'*d: continue days_ = '' for j in range(len(days)): if i<=j