#include <bits/stdc++.h>
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
long long fast_exp(long long base, long long exp) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % 1000000007;
    base = (base * base) % 1000000007;
    exp /= 2;
  }
  return res % 1000000007;
}
int gcd(int a, int b) {
  while (a && b) a > b ? a %= b : b %= a;
  return a + b;
}
int val(char c) {
  if (c >= '0' && c <= '9')
    return (int)c - '0';
  else
    return (int)c - 'A' + 10;
}
long long pows(int a, int b) {
  long long res = 1;
  for (int i = 0; i < b; ++i) {
    res *= a;
  }
  return res;
}
long long logx(long long base, long long num) {
  int cnt = 0;
  while (num != 1) {
    num /= base;
    ++cnt;
  }
  return cnt;
}
long long divisibles(long long a, long long b, long long m) {
  if (a % m == 0)
    return (b / m) - (a / m) + 1;
  else
    return (b / m) - (a / m);
}
string bitstring(int n, int size) {
  string s;
  while (n) {
    s += (n % 2) + '0';
    n /= 2;
  }
  while (s.size() < size) {
    s += '0';
  }
  reverse(s.begin(), s.end());
  return s;
}
vector<int> root(200001, 0);
vector<int> size(200001, 1);
int find(int x) {
  while (x != root[x]) x = root[x];
  return x;
}
bool same(int a, int b) { return find(a) == find(b); }
void unite(int a, int b) {
  a = find(a);
  b = find(b);
  if (size[a] < size[b]) swap(a, b);
  size[a] += size[b];
  root[b] = a;
}
vector<int> vis(200001, 0);
vector<int> adj[200001];
int matrix[1001][1001];
int path[1001][1001];
vector<int> vecxpath;
void pathprint(int u, int v) {
  if (path[u][v] == -1) return;
  vecxpath.push_back(u);
  while (u != v) {
    u = path[u][v];
    vecxpath.push_back(u);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int total = (n * (n - 1)) / 2;
  set<pair<int, int>> setx;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      matrix[i][j] = INT_MAX;
      if (i == j) {
        matrix[i][j] = 0;
        path[i][j] = i;
      }
      path[i][j] = -1;
    }
  }
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    matrix[a][b] = c;
    matrix[b][a] = c;
    path[a][b] = b;
    path[b][a] = a;
  }
  for (int k = 1; k <= n; ++k) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        if (matrix[i][j] > (matrix[i][k] + matrix[k][j])) {
          matrix[i][j] = matrix[i][k] + matrix[k][j];
          path[i][j] = path[i][k];
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      pathprint(i, j);
      if (!vecxpath.size()) continue;
      for (int k = 0; k < vecxpath.size() - 1; ++k) {
        int s = vecxpath[k];
        int e = vecxpath[k + 1];
        if (setx.count(make_pair(e, s))) continue;
        setx.insert(make_pair(s, e));
      }
      vecxpath.clear();
    }
  }
  cout << total - setx.size() << "\n";
}
