#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
int V, E;
int d[100][100];
vector<int> G[100];
int main() {
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      d[i][j] = INF;
    }
  }
  cin >> V >> E;
  for (int i = 0; i < E; i++) {
    int A, B, C;
    cin >> A >> B >> C;
    A--;
    B--;
    d[A][B] = C;
    d[B][A] = C;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  set<pair<int, int> > s;
  for (int S = 0; S < V; S++) {
    for (int i = 0; i < (int)G[S].size(); i++) {
      int num = G[S][i];
      for (int j = 0; j < (int)G[num].size(); j++) {
        int mum = G[num][j];
        if (d[S][num] + d[num][mum] == d[S][mum]) {
          s.insert(make_pair(min(S, num), max(S, num)));
          s.insert(make_pair(min(num, mum), max(num, mum)));
        }
      }
    }
  }
  cout << E - (int)s.size() << endl;
  return 0;
}
