#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#define P printf
#define S scanf
using namespace std;
int n,m,k,b[10001],c,k1;
vector <pair<int, int> > v[10001];
queue <int> q;
map <int, int> f[10001];
map <int, int>::iterator it;
int main ()
{
    S("%d%d%d",&n,&m,&k);
    for (int i=1; i<=m; i++)
    {
        int x,y,z;
        S("%d%d%d",&x,&y,&z);
        v[x].push_back(make_pair(y,z));
        b[y]++;
    }
    q.push(1);
    f[1][0]=1;
    for (;!q.empty();)
    {
        int pos=q.front();
        for (int i=0; i<v[pos].size(); i++)
        {
            int l,t;
            l=v[pos][i].first;
            t=v[pos][i].second;
            b[l]--;
            for (it=f[pos].begin(); it!=f[pos].end(); it++)
                f[l][max(it->first,t)]+=it->second;
            if (b[l]==0)
                q.push(l);
        }
        q.pop();
    }
    for (it=f[n].begin(); it!=f[n].end(); it++)
    {
        c=it->first;
        k1+=it->second;
        if (k1>=k)
            break;
    }
    P("%d\n",c);
    return 0;
}
/*
5 6 2
1 2 2
1 3 3
2 5 3
3 5 2
1 4 1
4 5 4

7 9 4
1 5 1
1 2 2
5 2 2
2 3 2
2 4 1
3 4 2
4 6 2
4 7 1
6 7 3
*/
