#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int mod = 1e9 + 7;
struct edge {
  int to, cost;
};
vector<vector<edge> > graph;
int n, m;
int d[105][105];
bool used[105][105];
void warshall_floyd() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          used[i][k] = true;
          used[k][i] = true;
          used[j][k] = true;
          used[k][j] = true;
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
}
int main(void) {
  cin >> n >> m;
  graph = vector<vector<edge> >(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;
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;
    d[x][y] = c;
    d[y][x] = c;
    cnt += 2;
  }
  warshall_floyd();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (used[i][j]) {
        ans++;
      }
    }
  }
  cout << (cnt - ans) / 2 << endl;
  return 0;
}
