public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		double V = in.nextDouble();
		int A = in.nextInt();
		int B = in.nextInt();
		ArrayList<Link> links = new ArrayList<Link>();
		for (int i = 0; i < M; i++)
		{
			int first = in.nextInt();
			int second = in.nextInt();
			double conversionRate = in.nextDouble();
			links.add(new Link(first, second, conversionRate));
		}
		
		double[] distance = new double[N+1];
		int[] predecessor = new int[N+1];
		for (int i = 0; i <= N; i++)
		{
			distance[i] = Double.POSITIVE_INFINITY;
			predecessor[i] = -1;
		}
		distance[A] = V;
		
		for (int i = 0; i < M; i++)
			for (int j = 0; j < links.size(); j++)
			{
				Link current = links.get(j);
				int src = current.src;
				int dest = current.dest;
				double conv = current.conv;
				if (distance[src] * conv < distance[dest])
				{
					distance[dest] = distance[src] * conv;
					predecessor[dest] = src;
				}
			}
		
		boolean cycle = false;
		for (int i = 0; i < links.size(); i++)
		{
			Link current = links.get(i);
			int src = current.src;
			int dest = current.dest;
			double conv = current.conv;
			if (distance[src] * conv < distance[dest])
				cycle = true;
		}
		
		if (cycle)
			System.out.println(0);
		else
			System.out.println(Math.round(distance[B]));
			
	}