#include <bits/stdc++.h>usingnamespacestd;
typedeflonglong ll;
typedef pair<int,int> pii;
#define mp make_pair#define pb push_back#define fi first#define se secondconstint inf = 0x3f3f3f3f;
constdouble eps = 1e-8;
int n,m;
int num = 0;
constint maxn = 1e5 + 5;
vector<int> g[maxn];
int ru[maxn];
ll ans = 0;
int dp[maxn];
int main(){
//freopen("out.txt","r",stdin);cin>>n>>m;
for (int i=0;i<m;i++){
int u,v;
scanf("%d%d",&u,&v);
ru[v]++;
ru[u]++;
if (v > u){
g[u].pb(v);
}
else{
g[v].pb(u);
}
}
for (int i=1;i<=n;i++){
dp[i] = 1;
}
for (int u=1;u<=n;u++){
for (int i=0;i<g[u].size();i++){
int v = g[u][i];
dp[v] = max(dp[v],dp[u]+1);
}
ans = max(ans,(ll)dp[u] * (ll)ru[u]);
}
cout << ans <<"\n";
return0;
}