#include <cstdio>
#include <vector>
#include <fstream>
#include <iostream>
using namespace std;
typedef int lld;

struct Awesome
{
    lld vert,dist;
};
vector<Awesome> Graph[100003];
vector<lld> Q;

lld n,m,k;

lld BFS(lld pokoki)
{
    Q.clear();
    lld cnt=0;
    lld indr=0,i;
    Awesome helper;

    Q.push_back(1);

    while (indr<Q.size())
    {
        if (Q[indr]==n)
        {
            cnt++;
        }
        for (i=0;i<Graph[Q[indr]].size();i++)
        {
            if (Graph[Q[indr]][i].dist>pokoki)
            {
                continue;
            }
            Q.push_back(Graph[Q[indr]][i].vert);
        }
        indr++;
    }
    return cnt;
}

int main ()
{
    ios::sync_with_stdio(false);
    lld i,j,ii,jj,ind,l,r,mid,v,ans=0;
    lld a,b,c,emin=99999999,emax=-1;
    Awesome helper;

    cin>>n>>m>>k;
    for (i=1;i<=m;i++)
    {
        cin>>a>>b>>c;
        helper.dist=c;

        helper.vert=b;
        Graph[a].push_back(helper);

        if (c<emin) emin=c;
        if (c>emax) emax=c;
    }
    l=emin;
    r=emax;
    while (l<=r)
    {
        mid=(l+r)/2;

        v=BFS(mid);
        if (v<k)
        {
            l=mid+1;
        }
        else
        {
            ans=mid;
            r=mid-1;
        }
    }
    cout<<ans<<endl;
}

