#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
const int INF = 1e9;
struct edge {
  int to, cost;
};
int n, m;
vector<edge> graph[MAXN];
int dist[MAXN][MAXN];
void solve() {
  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] = INF;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      dist[i][graph[i][j].to] = graph[i][j].cost;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < n; k++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      if (graph[i][j].cost > dist[i][graph[i][j].to]) {
        cnt++;
      }
    }
  }
  cout << (cnt / 2) << endl;
}
int main() {
  cin >> n >> m;
  int a, b, c;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    graph[--a].push_back((edge){--b, c});
    graph[b].push_back((edge){a, c});
  }
  solve();
}
