#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 5;
const int mod = 1e9 + 7;
int n, m;
int mp[maxn][maxn];
int dis[maxn][maxn];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i == j)
        dis[i][j] = 0;
      else
        dis[i][j] = 0x3f3f3f3f;
  for (int a, b, c, i = 0; i < m; i++) {
    scanf("%d %d %d", &a, &b, &c);
    mp[a][b] = mp[b][a] = c;
    dis[a][b] = dis[b][a] = c;
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (dis[i][j] > dis[i][k] + dis[k][j])
          dis[i][j] = dis[i][k] + dis[k][j];
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        if (dis[i][j] == dis[i][k] + mp[k][j]) {
          mp[k][j] = 0x3f3f3f3f;
          mp[j][k] = 0x3f3f3f3f;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (i != j && mp[i][j] != 0x3f3f3f3f) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
