import java.util.Scanner;

public class Main2{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int[] b = new int[m];
		int[] c = new int[m];

		int[][] dist = new int[n][n];

		for(int i = 0; i < n; i++){
			for(int j =0; j<n; j++){
				if(i==j) dist[i][j] = 0;
				else dist[i][j] = (int)1e9;
			}
		}
		for(int i=0; i<m; i++){
			a[i] = sc.nextInt()-1;
			b[i] = sc.nextInt()-1;
			c[i] = sc.nextInt();

			dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
		}

		for(int k=0; k<n; k++){
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					dist[i][j] = Math.min(dist[i][k] + dist[k][j], dist[i][j]);
				}
			}
		}

		int count =0;
		for(int i=0; i<m; i++){
			if(c[i] > dist[a[i]][b[i]]) count++;
		}

		System.out.println(count);
	}
}