#include <bits/stdc++.h>
using namespace std;
int n, m, f[110][110], ans;
struct edge {
  int to, ca;
};
vector<edge> map[110];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) f[i][j] = 1 << 30;
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    edge x;
    x.to = b;
    x.ca = c;
    map[a].push_back(x);
    x.to = a;
    map[b].push_back(x);
    f[a][b] = c;
    f[b][a] = c;
  }
  for (int i = 1; i <= n; i++) f[i][i] = 0;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (i != j && f[i][k] + f[k][j] < f[i][j]) {
          f[i][j] = f[i][k] + f[k][j];
        }
  ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < map[i].size(); j++) {
      bool T = false;
      for (int s = 1; s <= n; s++) {
        for (int t = 1; t <= n; t++)
          if (s != t &&
                  f[s][t] == f[s][i] + f[map[i][j].to][t] + map[i][j].ca ||
              f[s][t] == f[s][map[i][j].to] + f[i][t] + map[i][j].ca) {
            T = true;
            break;
          }
        if (T) break;
      }
      if (!T) {
        ans++;
      }
    }
  }
  printf("%d\n", ans / 2);
  return 0;
}
