### constant

INF = 1 << 30

### main

loop do
  n, m, c = gets.split.map(&:to_i)
  break if (n | m | c) == 0

  edges = n.times.map{n.times.map{nil}}
  nbrs = n.times.map{[]}

  m.times do
    fi, ti, ci = gets.split.map(&:to_i)
    fi -= 1
    ti -= 1
    edges[fi][ti] = ci
    nbrs[fi] << ti
  end
  #p edges
  #p nbrs

  dists = n.times.map{(m + 1).times.map{INF}}
  dists[0][0] = 0

  q = [[0, 0]]
  min_k = m + 1
  
  while ! q.empty?
    u = q.min{|a, b| dists[a[0]][a[1]] <=> dists[b[0]][b[1]]}
    q.delete(u)

    ui, uk = u
    ud = dists[ui][uk]
    
    if ui == n - 1
      min_k = uk if ud <= c && min_k > uk
      next
    end

    for vi in nbrs[ui]
      nvd = ud + edges[ui][vi]
      if dists[vi][uk] > nvd
        dists[vi][uk] = nvd
        q << [vi, uk]
      end

      if uk < m && dists[vi][uk + 1] > ud
        dists[vi][uk + 1] = ud
        q << [vi, uk + 1]
      end
    end
  end

  #p dists[n - 1]
  puts min_k
end