#include<cstdio>
#include<queue>
using namespace std;
const int N=50010;
struct node{
int v,next;
double w;
}e1[N<<5],e2[N<<5];
int tot,n,m,head1[N],head2[N];
double dis[N],eps;
bool vis[N];
struct data{
double f,g;//f表示经过当前节点的最短路,g表示S->当前节点的最短路
int from;//记录当前节点编号
data(int x,double y,double z):from(x),f(y),g(z){}
bool operator < (const data &a) const {
if(f==a.f) return g>a.g;
return f>a.f;
}
};
inline void read(int &x){
register char ch=getchar();x=0;
while(ch>‘9‘||ch<‘0‘) ch=getchar();
while(ch>=‘0‘&&ch<=‘9‘) x=(x<<3)+(x<<1)+ch-‘0‘,ch=getchar();
}
void add(int x,int y,double z){
++tot;
e1[tot].v=y;e1[tot].w=z;e1[tot].next=head1[x];head1[x]=tot;
e2[tot].v=x;e2[tot].w=z;e2[tot].next=head2[y];head2[y]=tot;
}
void spfa(int S){//更新每个点->n点的最短距离
for(int i=1;i<=n;i++) dis[i]=0x3f3f3f3f;
dis[S]=0;
queue<int>q;
q.push(S);
vis[S]=1;
while(!q.empty()){
int h=q.front();q.pop();
vis[h]=0;
for(int i=head2[h];i;i=e2[i].next){
int v=e2[i].v,w=e2[i].w;
if(dis[v]>dis[h]+w){
dis[v]=dis[h]+w;
if(!vis[v]){
vis[v]=1;
q.push(v);
}
}
}
}
}
int a_star(int S,int T){
priority_queue<data>q;
int cnt=0;
double total=0;
q.push(data(S,dis[S],0));
while(!q.empty()){
data h=q.top();q.pop();
if(total>eps) return cnt;//返回第k短路
if(h.from==T) cnt++,total+=h.f;
for(int i=head1[h.from];i;i=e1[i].next){
q.push(data(e1[i].v,h.g+e1[i].w+dis[e1[i].v],h.g+e1[i].w));//最短路更新k短路
}
}
}
int main(){
int x,y;double z;
read(n);read(m);
scanf("%lf",&eps);
for(int i=1;i<=m;i++){
read(x);read(y);
scanf("%lf",&z);
add(x,y,z);
}
spfa(n);
int ans=a_star(1,n);
printf("%d\n",ans-1);//注意最后-1,要不然就超了
return 0;
}