#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
#define MAXN 1000005
#define lowbit(x) (x&-x)
#define reg register
#define mp make_pair
#define fir first
#define sec second
typedef long long LL;
typedef unsigned long long uLL;
const int INF=0x7f7f7f7f;
const int jzm=233;
const int mo=1e9+7;
const int zero=200;
const double Pi=acos(-1.0);
typedef pair<int,int> pii;
const double PI=acos(-1.0);
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=getchar();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=getchar();}
	while('0'<=s&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=getchar();}
	x*=f;
}
LL k,n,dp[5][MAXN*3];
signed main(){
	read(n);read(k);
	for(LL i=1;i<=n;i++)dp[1][i]=1LL,dp[1][i]+=dp[1][i-1];
	for(LL i=n+1;i<=3*n;i++)dp[1][i]=dp[1][n];
	for(LL i=2;i<=2*n;i++)dp[2][i]+=dp[1][i-1]-dp[1][max(0LL,i-n-1LL)],dp[2][i]+=dp[2][i-1];
	for(LL i=2*n+1;i<=3*n;i++)dp[2][i]=dp[2][2*n];
	for(LL i=3;i<=3*n;i++)dp[3][i]+=dp[2][i-1]-dp[2][max(0LL,i-n-1LL)];
	for(LL i=3;i<=3*n;i++){
		//printf("%lld %lld %lld %lld\n",k,dp[3][i],dp[2][i]-dp[2][i-1],dp[1][i]-dp[1][i-1]);
		if(k<=dp[3][i]){
			for(LL j=1;j<=n;j++){
				if(i-j>2*n)continue;
				LL down=max(1LL,i-j-n),up=min(n,i-j-1);
				//printf("%lld:%lld %lld\n",j,up,down);
				if(k>up-down+1LL)k-=(up-down+1LL);
				else{
					printf("%lld %lld %lld\n",j,down+k-1LL,i-j-down-k+1LL);
					return 0;
				}
			}
		}
		else k-=dp[3][i];
	}
	return 0;
}
/*
3:1
4:3
5:3
6:1
*/
#include <bits/stdc++.h>
using namespace std;
int fastio() { ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); cin.tie(nullptr); return 0; }
int __fastio = fastio();

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
typedef long long ll;
typedef pair<ll, ll> ii;
#define fi first
#define se second
#define sz(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

int main(){
    ll n;
    cin >> n;
    ll res = 1;
    set<ll> can;
    // sqrtN
    for(ll i=2;i*i<=n;i++) {
        if(can.count(i)) continue;
        ll cur = i;
        // logN
        while(cur*i <= n) {
            cur *= i;
            can.insert(cur);
        }
    }
    cout << n - can.size() << "\n";
}
