#include <bits/stdc++.h>
using namespace std;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dx9[9] = {0, 1, 0, -1, 1, -1, 1, 0, -1};
int dy9[9] = {0, 1, 1, 1, 0, 0, -1, -1, -1};
const int INF = 1e9;
const long long LLINF = 1e18;
const int MAX_V = 1e6 + 1;
const long long mod = 1000000007;
int n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  int g[100][100] = {INF};
  for (int i = 0; i < (int)(m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = c;
    g[b][a] = c;
  }
  int count = 0;
  for (int i = 0; i < (int)(n); i++)
    for (int j = (i + 1); j < (int)(n); j++) {
      int x = g[i][j];
      int y = INF * 2;
      for (int k = 0; k < (int)(n); k++)
        if (i != k && k != j) {
          int ty = g[i][k] + g[k][j];
          y = min(y, ty);
        }
      if (x != INF && x > y) count++;
    }
  cout << count << endl;
}
