#include <bits/stdc++.h>
using namespace std;
class BLongtailHedgehog {
 public:
  int N, M;
  vector<int> dist, deg_in, deg;
  vector<vector<int>> G;
  void input(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in >> N >> M;
    dist = vector<int>(N, -1);
    deg_in = vector<int>(N, 0);
    deg = vector<int>(N, 0);
    G = vector<vector<int>>(N, vector<int>());
    for (int(i) = (0); (i) < (M); ++(i)) {
      int u, v;
      in >> u >> v;
      u--, v--;
      if (u > v) swap(u, v);
      G[u].push_back(v);
      deg_in[v]++, deg[u]++, deg[v]++;
    }
  }
  void bfs(int s) {
    queue<int> q;
    dist[s] = 1, q.push(s);
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (auto v : G[u]) {
        deg_in[v]--;
        dist[v] = max(dist[v], dist[u] + 1);
        if (deg_in[v] == 0) {
          q.push(v);
        }
      }
    }
  }
  void solve(std::istream& in, std::ostream& out) {
    input(in, out);
    for (int(i) = (0); (i) < (N); ++(i)) {
      if (dist[i] == -1) bfs(i);
    }
    long long ans = 0;
    for (int(i) = (0); (i) < (N); ++(i)) ans = max(ans, 1LL * dist[i] * deg[i]);
    out << ans << '\n';
  }
};
int main() {
  BLongtailHedgehog solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
