#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m,a[1005],b[1005],c[1005],d[105][105],res;
int main()
{
    scanf("%d%d",&n,&m);
    memset(d,0x3f,sizeof d);
    for (int i=0;i<m;++i) {
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        d[a[i]][b[i]]=d[b[i]][a[i]]=c[i];
    }
    for (int i=1;i<=n;++i)
        d[i][i]=0;
    for (int k=1;k<=n;++k)
        for (int i=1;i<=n;++i)
            for (int j=1;j<=n;++j)
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    for (int i=0;i<m;++i) {
        bool f=true;
        for (int j=1;j<=n;++j)
            for (int k=1;k<=n;++k)
                if (d[j][a[i]]+d[b[i]][k]+c[i]==d[j][k])
                    f=false;
        res+=f;
    }
    printf("%d\n",res);
    return 0;
}
