#include using namespace std; struct matrix{ vector> a; matrix():a(100){} matrix operator*(const matrix& x) const { matrix ans; for(int i = 0; i < 100; i++) for(int j = 0; j < 100; j++) if(a[i][j]) ans[i] |= x[j]; return ans; } bitset<100>& operator[](int x){ return a[x]; } const bitset<100>& operator[](int x) const { return a[x]; } matrix pow(uint64_t x) const { matrix ans, a = *this; for(int i = 0; i < 100; i++) ans[i][i] = 1; while(x){ if(x & 1) ans = ans * a; a = a * a; x >>= 1; } return ans; } }; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int N, M; long T; cin >> N >> M >> T; matrix a; while(M--){ int x, y; cin >> x >> y; a[x][y] = 1; } cout << a.pow(T)[0].count() << endl; }