#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
#define pb push_back
#define T ll testx; cin>>testx; while(testx--)
#define print(name) for(auto t:name){cout<<t<<" ";}cout<<endl;
#define printii(name) for(auto t:name){cout<<t.first<<" "<<t.second<<endl;}
#define mod 1000000007
#define modx 998244353
#define inf 2000000000000000000
#define mem(name,val) memset(name,val,sizeof(name))
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define endl "\n"
#define popcount(x) __builtin_popcountll(x)
#define precise cout<<fixed<<setprecision(15)
const long double pi = acos(-1);
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}
void dfs(int s,vector<int>adj[],int vis[])
{
   vis[s]=1;
   for(auto x:adj[s])
   {
      if(vis[x]==0)
      {
         dfs(x,adj,vis);
      }
   }
}
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif 
    int n,m,x,y;cin>>n>>m;int vis[n+1];mem(vis,0);vector<int>adj[n+1];
    f(m)
    {
      cin>>x>>y;
      adj[x].pb(y);
    }
    
    ll sum=0;
    for(int i=1;i<=n;i++){
      mem(vis,0);
     dfs(i,adj,vis);
     //cout<<sum<<endl;
     for(int j=1;j<=n;j++){if(vis[j]==1){sum=sum+1;}}
 }
cout<<sum;
}
#include<bits/stdc++.h>
#define x first
#define y second
#define bug(x) cerr<<#x<<'='<<x<<' '
#define debug(x) cerr<<#x<<'='<<x<<'\n'
#define FOR(a,b,c) for(int a=(b),a##_end=(c);a<=a##_end;++a)
#define ROF(a,b,c) for(int a=(b),a##_end=(c);a>=a##_end;--a)
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int INF=0x3f3f3f3f,N=1e5+10;
template<class T>inline bool chkmin(T &x,const T &y){return y<x?x=y,1:0;}
template<class T>inline bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
int tot,pri[N],son[N];
void Sieve(){
	static bool is[N];
	memset(is,true,sizeof(is));
	FOR(i,2,N-1){
		if(is[i])son[pri[++tot]=i]=i;
		for(int j=1,t;j<=tot&&(t=i*pri[j])<N;++j){
			is[t]=false;
			son[t]=pri[j];
			if(i%pri[j]==0)break;
		}
	}
}
int main(){
	Sieve();
	int n;
	scanf("%d",&n);
	FOR(i,1,n){
		int x=i,cnt=1;
		while(x!=1){
			++cnt;
			x/=son[x];
		}
		printf("%d ",cnt);
	}
	putchar('\n');
	return 0;
}