#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int INF = 100100100;
const int MAX_V = 1100;
int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V;
int previ[MAX_V];

void dijkstra(int s){
    fill(d, d+V, INF);
    fill(used, used+V, false);
    fill(previ, previ+V, -1);
    d[s] = 0;

    while(true){
        int v = -1;
        rep(u,V){
            if(!used[u] && (v==-1 || d[u]<d[v]))v=u;
        }
        if(v==-1)break;
        used[v] = true;

        for(int u=0;u<V;u++){
            if(d[u]>d[v]+cost[v][u]){
                d[u] = d[v] + cost[v][u];
                previ[u] = v;
            }
        }
    }
}

vector<int> get_path(int t){
    vector<int> path;
    for(;t!=-1;t=previ[t])path.push_back(t);
    reverse(path.begin(), path.end());
    return path;
}

int main() {
    cin >> V;
    rep(i,V){
        rep(j,V){
            if(i==j){
                cost[i][j] = 0;
            }else{
                cost[i][j] = INF;
            }
        }
    }
    int E;
    rep(i,E){
        int from,to,c;
        cin >> from >> to >> c;
        from--;
        to--;
        cost[from][to] = c;
        cost[to][from] = c;
    }

    flag[V][V];
    rep(i,V){
        rep(j,V){
            flag[i][j] = 0;
        }
    }

    rep(i,V){
        dijkstra(i);
        rep(j,V){
            vi v = get_path(j);
            int from = i;
            rep(k,v.size()){
                flag[from][v[k]] = 1;
                from = v[k];
            }
        }
    }

    int ans = 0;
    rep(i,V){
        rep(j,V){
            if(i!=j && cost[i][j]!=INF){
                if(flag[i][j]==0)ans++;
            }
        }
    }

    cout << ans/2 << endl;

    return 0;
}
 
 
