using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = ReadLine().Split(); var (n, m, t) = (int.Parse(c[0]), int.Parse(c[1]), long.Parse(c[2])); var map = NArr(m); if (t == 0) { WriteLine(1); return; } var x = new int[n][]; for (var i = 0; i < n; ++i) x[i] = new int[n]; foreach (var edge in map) x[edge[0]][edge[1]] = 1; var a = new int[][] { new int[n] }; a[0][0] = 1; var b = Matrix.Mul(a, Matrix.Pow(x, t)); WriteLine(b[0].Count(bi => bi == 1)); } class Matrix { // 行列の累乗 public static int[][] Pow(int[][] m, long k) { var multi = m; var r = new int[m.Length][]; for (var i = 0; i < m.Length; ++i) { r[i] = new int[m.Length]; r[i][i] = 1; } while (k > 0) { if ((k & 1) == 1) r = Mul(r, multi); multi = Mul(multi, multi); k >>= 1; } return r; } // 行列の積 public static int[][] Mul(int[][] x, int[][] y) { var r = new int[x.Length][]; for (var i = 0; i < x.Length; ++i) r[i] = new int[y[0].Length]; for (var i = 0; i < x.Length; ++i) for (var k = 0; k < x[0].Length; ++k) { for (var j = 0; j < y[0].Length; ++j) r[i][j] = r[i][j] + x[i][k] * y[k][j]; } for (var i = 0; i < r.Length; ++i) for (var j = 0; j < r[i].Length; ++j) if (r[i][j] != 0) r[i][j] = 1; return r; } } }