// Slower C++ solution:
#include <bits/stdc++.h>

#define maxn 109

#define maxm 1009

using namespace std;

struct Edge

{

	int v,w,next;

}edge[maxm];

int n,m,tot,head[maxn];

int d[maxn][maxm],inq[maxn][maxm];

inline void addedge(int u,int v,int w)

{

	edge[tot].v=v;

	edge[tot].w=w;

	edge[tot].next=head[u];

	head[u]=tot++;

}

queue<pair<int,int> >Q;

void spfa()

{

	memset(d,0x3f,sizeof(d));

	d[1][0]=0;

	Q.push(make_pair(1,0));

	pair<int,int>tmp;

	while(!Q.empty())

	{

		tmp=Q.front();

		Q.pop();

		int x=tmp.first;

		int y=tmp.second;

		inq[x][y]=0;

		for(int e=head[x];e!=-1;e=edge[e].next)

		{

			int v=edge[e].v;

			if(y<m&&d[v][y+1]>d[x][y])

			{

				d[v][y+1]=d[x][y];

				if(!inq[v][y+1])

				{

					inq[v][y+1]=1;

					Q.push(make_pair(v,y+1));

				}

			}

			if(d[v][y]>d[x][y]+edge[e].w)

			{

				d[v][y]=d[x][y]+edge[e].w;

				if(!inq[v][y])

				{

					inq[v][y]=1;

					Q.push(make_pair(v,y));

				}

			}

		}

	}

}

int main()

{

	int u,v,w,c;

	while(scanf("%d%d%d",&n,&m,&c),n+m+c)

	{

		memset(head,-1,sizeof(head));

		tot=0;

		for(int i=1;i<=m;i++)

		{

			scanf("%d%d%d",&u,&v,&w);

			addedge(u,v,w);

		}

		spfa();

		int ans=m;

		for(int i=0;i<=m;i++)

		{

			if(d[n][i]<=c)

			{

				ans=i;

				break;

			}

		}

		printf("%d\n",ans);

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4444879034020464x):
#include <iostream>

#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <queue>

#include <map>

#include <set>

#include <vector>

#include <string>

#include <stack>

#include <bitset>

#define INF 0x3f3f3f3f

#define eps 1e-8

#define FI first

#define SE second

using namespace std;

typedef long long LL;

vector < pair<int,int> > G[105];



queue < pair<int,int> > Q;

int dis[105][105], n, m, C;

bool inq[105][105];

void Spfa(int S) {

    memset(dis, 0x3f, sizeof(dis));

    dis[S][0] = 0;

    for(int i = 1; i <= n; ++i) dis[i][n] = 0;

    Q.push(make_pair(S, 0));

    pair <int,int> t;

    while(!Q.empty()) {

        t = Q.front(); Q.pop();

        inq[t.FI][t.SE] = 0;

        int u = t.FI;

        if(u == n && dis[u][t.SE] <= C) continue;

        for(int i = 0; i < (int)G[u].size(); ++i) {

            int v = G[u][i].FI, w = G[u][i].SE;

            if(dis[v][t.SE] > dis[u][t.SE] + w) {

                dis[v][t.SE] = dis[u][t.SE] + w;

                if(!inq[v][t.SE]) Q.push(make_pair(v, t.SE)),inq[v][t.SE] = 1;

            }

            if(dis[v][t.SE + 1] > dis[u][t.SE]) {

                dis[v][t.SE + 1] = dis[u][t.SE];

                if(!inq[v][t.SE + 1]) Q.push(make_pair(v, t.SE + 1)),inq[v][t.SE + 1] = 1;

            }

        }

    }

}



int main() {

    while(scanf("%d%d%d", &n, &m, &C)) {

        if(n + m + C == 0) break;

        for(int i = 0; i < n; ++i) G[i].clear();

        for(int i = 0; i < m; ++i) {

            int u, v, w;

            scanf("%d%d%d", &u, &v, &w);

            G[u].push_back(make_pair(v, w));

        }

        Spfa(1);

        for(int i = 0; i <= n; ++i) if(dis[n][i] <= C) {

            printf("%d\n", i);

            break;

        }

    }

    return 0;

}