n, edgeCount, timeLimit = map(int, input().split()) doubling = [[[False] * n for _ in range(n)] for _ in range(61)] for _ in range(edgeCount): u, v = map(int, input().split()) doubling[0][u][v] = True for d in range(60): for u in range(n): for v in range(n): for w in range(n): doubling[d + 1][u][w] |= doubling[d][u][v] and doubling[d][v][w] current = [False] * n current[0] = True for d in range(60): if ((timeLimit >> d) & 1) > 0: nxt = [False] * n for u in range(n): if current[u]: for v in range(n): nxt[v] |= doubling[d][u][v] current = nxt count = 0 for v in range(n): if current[v]: count += 1 print(count)