#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > v;
int main() {
  long long n, m, i, j, k, a, b;
  scanf("%lld", &n);
  scanf("%lld", &m);
  long long dp[n + 1], d[n + 1];
  memset(dp, 0, sizeof dp);
  memset(d, 0, sizeof d);
  for (i = 0; i < m; i++) {
    scanf("%lld", &a);
    scanf("%lld", &b);
    d[a]++;
    d[b]++;
    j = min(a, b);
    k = max(a, b);
    pair<long long, long long> a = make_pair(j, k);
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  for (i = 0; i < m; i++) {
    pair<long long, long long> pp = v[i];
    dp[pp.second] = max(dp[pp.second], 1 + dp[pp.first]);
  }
  long long mx = -1;
  for (i = 1; i <= n; i++) {
    j = (dp[i] + 1) * d[i];
    if (j > mx) mx = j;
  }
  printf("%lld\n", mx);
  return 0;
}
