#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int dist[105][105];
int nextv[105][105];
bool used[105][105];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  fill((int*)dist, (int*)(dist + n), INF);
  for (int i = 0; i < n; ++i) {
    dist[i][i] = 0;
  }
  fill((int*)nextv, (int*)(nextv + n), -1);
  fill((bool*)used, (bool*)(used + n), true);
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    dist[a][b] = c;
    dist[b][a] = c;
    nextv[a][b] = b;
    nextv[b][a] = a;
    used[a][b] = false;
    used[b][a] = false;
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
          nextv[i][j] = k;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cerr << used[i][j] << " ";
    }
    cerr << endl;
  }
  cerr << endl;
  for (int s = 0; s < n; ++s) {
    for (int t = 0; t < n; ++t) {
      if (s == t) continue;
      int now = s;
      for (int v = s; v != t; v = nextv[v][t]) {
        used[now][v] = true;
        now = v;
      }
      used[now][t] = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (!used[i][j]) ++ans;
    }
  }
  cout << ans / 2 << endl;
}
