#include <bits/stdc++.h>
using namespace std;
const int INT_INF = 2147483646;
const long long LL_INF = 9223372036854775807;
bool SecondCompare(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second < b.second;
}
bool SecondCompareDes(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second > b.second;
}
long long minll(long long a, long long b) {
  if (a >= b)
    return b;
  else
    return a;
}
long long maxll(long long a, long long b) {
  if (a >= b)
    return a;
  else
    return b;
}
int dp[110][110];
int ans;
int used[110][110];
int che[110][110];
int mem_prev[110][110];
int n, m;
void warshall_floyd(int edge_num) {
  for (int k = 0; k < edge_num; k++) {
    for (int i = 0; i < edge_num; i++) {
      for (int j = 0; j < edge_num; j++) {
        if (dp[i][j] > (dp[i][k] + dp[k][j])) {
          mem_prev[i][j] = k;
          dp[i][j] = dp[i][k] + dp[k][j];
        }
      }
    }
  }
}
int main() {
  for (int i = 0; i < 110; i++) {
    for (int j = 0; j < 110; j++) {
      dp[i][j] = INT_INF / 2 - 100;
      che[i][j] = -1;
    }
  }
  for (int i = 0; i < 110; i++) {
    dp[i][i] = 0;
  }
  cin >> n >> m;
  int a, b, c;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    --a;
    --b;
    dp[a][b] = dp[b][a] = c;
    mem_prev[a][b] = a;
    mem_prev[b][a] = b;
    che[a][b] = che[b][a] = INT_INF;
  }
  warshall_floyd(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      che[j][mem_prev[i][j]] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (che[i][j] == INT_INF) {
        ++ans;
      }
    }
  }
  cout << ans / 2 << endl;
}
