#include <bits/stdc++.h>
int main() {
  int n, m;
  while (std::cin >> n >> m) {
    std::vector<int> mxLen(1 + n, 1), degree(1 + n);
    std::vector<std::vector<int>> next(1 + n);
    for (int i = 0, u, v; i < m; ++i) {
      std::cin >> u >> v;
      if (u > v) std::swap(u, v);
      next[u].push_back(v);
      degree[u]++;
      degree[v]++;
    }
    for (int u = 1; u < n; ++u) {
      for (int v : next[u]) {
        if (v > u) {
          mxLen[v] = std::max(mxLen[v], mxLen[u] + 1);
        }
      }
    }
    long long answ = 0;
    for (int u = 1; u <= n; ++u) {
      answ = std::max((long long)mxLen[u] * degree[u], answ);
    }
    std::cout << answ << std::endl;
  }
  return 0;
}
