#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
const int max_v = 100;
int d[max_v][max_v];
int V;
void warshall_floyd() {
  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]);
      }
    }
  }
}
void search(int now, int to, vector<vector<bool>> &used,
            const vector<vector<int>> &cost) {
  if (now == to) return;
  for (int i = 0; i < (int)cost.at(now).size(); i++) {
    if (cost.at(now).at(i) == INF) continue;
    if (d[now][to] == d[now][i] + cost.at(i).at(to)) {
      used.at(now).at(i) = true;
      used.at(i).at(now) = true;
      search(i, to, used, cost);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  V = n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = INF;
    }
  }
  vector<vector<int>> cost(n, vector<int>(n, INF));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    cost[a][b] = c;
    cost[b][a] = c;
  }
  warshall_floyd();
  vector<vector<bool>> used(n, vector<bool>(n));
  for (int from = 0; from < n; from++) {
    for (int to = from + 1; to < n; to++) {
      if (d[from][to] == cost.at(from).at(to)) used.at(from).at(to) = true;
      search(from, to, used, cost);
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (cost.at(i).at(j) != INF && !used.at(i).at(j)) cnt++;
    }
  }
  cout << cnt << endl;
}
