import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static final void main(String args[]) {
        new Main().solve();
    }

    void solve() {
        try (Scanner in = new Scanner(System.in)) {
            int n = in.nextInt();
            int m = in.nextInt();
            int a[] = new int[m];
            int b[] = new int[m];
            int c[] = new int[m];
            int x[][] = new int[n][n];
            init(x, 0xffffff);
            for (int i = 0; i < n; ++i) {
                x[i][i] = 0;
            }
            int s[] = new int[n];
            for (int i = 0; i < m; ++i) {
                a[i] = in.nextInt() - 1;
                b[i] = in.nextInt() - 1;
                c[i] = in.nextInt();
                x[a[i]][b[i]] = c[i];
                x[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) {
                        if (x[i][j] > x[i][k] + x[k][j]) x[i][j] = x[i][k] + x[k][j];
                    }
                }
            }
            int z = 0;
            for (int i = 0; i < m; ++i) {
                if (x[a[i]][b[i]] != c[i]) ++z;
            }
            System.out.println(z);
        }
    }

    void init(Object buf, int value) {
        if (buf instanceof int[]) {
            Arrays.fill((int[]) buf, value);
        } else if (buf instanceof Object[]) {
            for (Object o : (Object[]) buf) init(o, value);
        }
    }

    void tr(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}