#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int op = 0;
        while (j < n || i < n)
        {
            op += n - i;
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            op += n - j;
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            if (op > 4e8)
            {
                printf("YES\n");
                return 0;
            }
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int op = 0;
        while (j < n || i < n)
        {
            op += n - i;
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            op += n - j;
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            if (op > 4e8)
                break;
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int op = 0;
        while (j < n || i < n)
        {
            op += n - i;
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            op += n - j;
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            if (op > 1e8)
                break;
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int jlast = 0;
        int op;
        while (j < n || i < n)
        {
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            if (j == jlast)
                break;
            jlast = j;
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            op += 2 * n;
            //if (op >= 1e8)
            //    break;
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int op;
        while (j < n || i < n)
        {
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            op += 2 * n;
            if (op >= 1e8)
                break;
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


#include<stdio.h>
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int ans=0, h=0;
	while(1)
	{
		h++;
		long long int tem=n-(2*h);
		if(tem<0)break;
		if(tem%3==0)
		{
			long long int t = (h*(h+1))/2;
			t-=h;
			t*=3;
			if(tem>=t)ans++;
			else break;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long long n,h,k,s;
    scanf("%I64d",&n);
    h=0;
    if((n+1)%3==0)
        h++;
    s=7;
    k=5;
    for(s=7;s<=n;s=s+k)
    {
        if((n-s)%3==0)
            h++;
        k=k+3;
    }
    printf("%I64d\n",h);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int n;
	scanf("%lld",&n);
	long long int m=(-1+sqrt(1+24*n))/6;
	int i=(3+(3-n)%3)%3;
	int j=m%3;
	int k=0;
//	printf("%d %d",i,j);
	if(i<=j&&i!=0)
		k=1;
//	printf("%lld",m/3);
	printf("%lld",m/3+k);
	return 0;
}

#include<stdio.h>
#include<math.h>

void solve(long long int x)
{
    long long int n=(long long int)((sqrt(24*x + 1) - 1)/6.0);
    long long int ans=0,rem=x-(3*n*n+n)/2;
   // printf("%lld\n",rem);
    if(n>0)
    {
        if(rem%3==0)    ans=1;
        while(n>1)
        {
            if((rem+2)%3==0)
            {
                ans++;
            }
            rem+=2;
            n--;
        }
    }
    printf("%lld",ans);
}
int main()
{
    long long int n;
    scanf("%lld",&n);
    solve(n);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long i,A,cnt=0,cnt4;
    scanf("%I64d",&i);
    if(i%3==0){
        A=15;
        cnt4=3;
    }
    else if(i%3==2){
        A=2;
        cnt4=1;
    }
    else if(i%3==1){
        A=7;
        cnt4=2;
    }
    while(A<=i){
        cnt++;
        A=A+3*cnt4+2;
        cnt4++;
        A=A+3*cnt4+2;
        cnt4++;
        A=A+3*cnt4+2;
        cnt4++;
    }
    printf("%I64d",cnt);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long long int n,i,j,count=0;
    scanf("%lld",&n);

    //j=sqrt(n);
    j = (sqrt(1+24*n)-1)/6;
    for(i=1;i<=j;i++)
    {
        if((n+i)%3==0)
            count++;
    }

    printf("%lld\n",count);

    return 0;
}

#include<stdio.h>
int main(){
	long long int last,sum=2,i,j,k,l,n,m,rem;
	scanf("%lld",&n);
	m = 1;
	rem = 5;
	while(sum<n){
		m++;
		last = sum;
		sum = sum + rem;
		rem = rem + 3;
	}
//	printf("%lld %lld %lld\n",m,sum,last);
	if(sum==n){
		if(m%3==0)
			printf("%lld\n",m/3);
		else if(m%3==1)
			printf("%lld\n",m/3+1);
		else
			printf("%lld\n",m/3+1);
	}
	else{
		m--;
		if((n-last)%3==0){
			if(m%3==0)
				printf("%lld\n",m/3);
			else if(m%3==1)
				printf("%lld\n",(m/3)+1);
			else
				printf("%lld\n",(m/3)+1);
		}
		else if((n-last)%3==1){
			if(m%3==0)
				printf("%lld\n",(m)/3);
			else if(m%3==1){
				if(m>1)
					printf("%lld\n",m/3);
				else
					printf("0\n");}
			else
				printf("%lld\n",m/3+1);
		}
		else{
			if(m%3==0)
				printf("%lld\n",m/3);
			else if(m%3==1)
				printf("%lld\n",(m-1)/3);
			else
				printf("%lld\n",(m-2)/3);
		}
	}
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int n,a,b;
	scanf("%I64d",&n);
	b=(sqrt(1+24*n)-1)/6;
	a=3-n%3;
	printf("%I64d\n",a>b?0:(b-a)/3+1);
	return 0;
}

#include<stdio.h>
int main()
{
    long long int n,i,ans=0;
    scanf("%lld",&n);
    for(i=1;(3*i*(i+1)/2-i)<=n;i++)
    {
        if((n+i)%3==0)
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}

#include<stdio.h>
#include<string.h>
#define MAX 1000000//1-1000000�ۼ�Ϊ1e12
long long most[1000010];
int main(void)
{
	long long ans=0,n;
	scanf("%lld",&n);
	memset(most,0,sizeof(most));
	for(int i=1;i<=MAX;i++)
	{
		most[i]=3*i-1+most[i-1];
	}
	for(int i=1;i<=MAX;i++)
    {
		if(n>=most[i]&&(n-most[i])%3==0)
		{
			ans++;
		}
		if(n<most[i])
		    break;
	}
	printf("%lld\n",ans);
	return 0;
}

#include <stdio.h>

int main(void)
{
    long long n, v = 0;
    scanf("%I64d", &n);
    long long fmin = 3 - n % 3;
    for (long long f = fmin; n >= f * (3 * f + 1) / 2; f += 3)
        v++;
    printf("%I64d", v);
}

/* practice with Dukkha */
#include <stdio.h>

int main() {
	long long n, a, b;
	int ans;

	scanf("%lld", &n);
	ans = 0;
	for (a = 1; (b = a * (a + 1) / 2 * 3 - a) <= n; a++)
		if ((n - b) % 3 == 0)
			ans++;
	printf("%d\n", ans);
	return 0;
}

#include<stdio.h>
int main()
{
	long long int s=0,n,t,k=0,c=0;
	scanf("%I64d",&n);
	while(s<=n)
	{
		k++;
		s=3*k*(k+1)/2-k;
	}
	t=k;
	t=t-1;
	while(t)
	{
		if((n+t)%3==0)
		{
			c++;
		}
		t--;
	}
	printf("%ld\n",c);
	return 0;
}

#include<stdio.h>
int main()
{
	long long n,i;
	while(scanf("%lld",&n)!=EOF)
	{
		long long m,t,j,c,d=0;
		int s=0;
		for(i=1;i*i<=n;i++)
		{
			c=(n-2*i);
			t=c/3;
			d+=i-1;
			if(c%3==0&&t>=d)
			{
				s++;
			}
		}

			printf("%d\n",s);
	}
}

#include<stdio.h>
int main() {
	long long int i,j,n;
	while(scanf("%lld",&n)!=EOF){
		i=0;j=2;
		for(;n-j>=0;j+=3) {
			n-=j;
			if(n%3==0){
				i++;
			}
		}
		printf("%lld\n",i);
	}
	return 0;
}

#include<stdio.h>
#include<math.h>
typedef long long ll;
int main()
{
	ll n;
	scanf("%lld",&n);
	ll maxi=sqrt(n);
	int is=0;
	for(ll i=maxi;i>=0;i--)
	{
		if(3*(i+i*i)%2==0)
		{
			if(3*(i+i*i)/2+2*(i+1)<=n)
			{
				if((n-(3*(i+i*i)/2+2*(i+1)))%3==0)
				{
					is++;
				}
			}
		}
	}
	printf("%d",is);
}

#include<stdio.h>
#include<math.h>
typedef long long ll;
int main()
{
	ll n;
	scanf("%lld",&n);
	ll maxi=sqrt(n);
	int is=0;
	for(ll i=maxi;i>=1;i--)
	{
		if((3*i*i+i)/2<=n&&(n-(3*i*i+i)/2)%3==0)
		{
			is++;
		}

	}
	printf("%d",is);
}

#include <stdio.h>
#include <math.h>

#define ll long long

int main ()
{
    ll n, x, i;
    ll ans, yu, cha, mid;
    while (scanf("%I64d", &n) != EOF)
    {

        ans = 0;
        mid = (-1 + sqrt (1 + 24 * n)) / 6;
        if(3 * mid * mid + mid - 2 * n > 0){
            mid--;
        }
        while(mid)
        {

            if((n + mid) % 3 == 0){
                ans++;
            }
            mid--;
        }
        printf("%I64d\n", ans);
    }
    return 0;
}

#include <stdio.h>
#define LL long long
int main()
{
    LL n;
    int ans=0;
    scanf("%I64d",&n);
    int rem=n%3;
    LL q=n/3;
    LL start;
    if(rem==0)
    {
        start=3;
    }
    else if(rem==1)
    {
        start=2;
    }
    else
    {
        start=1;
    }
    LL lim=(start*(start+1))/2;
    while((q+ans+1)>=lim)
    {
        ans++;
        start+=3;
        lim=(start*(start+1))/2;
    }
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
int main()
{
    long long int i,n,count=0,h,rooms;
   scanf("%lld",&n);
    for(h=3-(n%3);;h=h+3)
    {
        rooms=(n+h)/3;
        if(rooms>=(h*(h+1))/2)
        count++;
        else
        break;
    }
    printf("%lld\n",count);
    return 0;
}

#include<stdio.h>
int main()
{
	long long n;
	while(scanf("%I64d",&n)!=EOF)
	{
		long long  a,b;
		a=n/3;
		b=n%3;

		long long  mi=0;if(b==2) mi=1;
		for(;;)
		{if(b%2==1) {b=b+3;a=a-1;}
			else  if(b%2==0){b=b+2*3 ; a=a-2; }

			 if(2*a>=b/2*(b/2-1))
			{
				mi++;
			}
			else
			{
				break;
			}

		}

		printf("%I64d\n",mi);
	}
}

#include <stdio.h>

typedef long long LL_t;

int main()
{
    LL_t h, N, Ans, F, E;
    scanf("%I64d", &N);
    h = 1;
    Ans = 0;
    while(1)
    {
        F = h*2 + h*(h-1)/2*3;
        if(F > N)
        {
            break;
        }
        E = N - F;
        if(E % 3 == 0)
        {
            ++Ans;
        }
        ++h;
    }
    printf("%I64d\n", Ans);
    return 0;
}

#include<stdio.h>
#define ll long long int
ll getcards(ll flo)
{
    return 3*flo*(flo+1)/2-flo;
}
//Another solution would be to calculate the number of rooms R i.e 3R-F everytime and then return the value.But it would become an O(n*sqrt(n));
int main()
{
    ll n;
    scanf("%lld",&n);

    ll floor;
    ll rem=0;
    for(floor=1;getcards(floor)<=n;floor++)
    {
        if((n+floor)%3==0)
            rem++;
    }

    printf("%lld",rem);

    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int n,a,b;
	scanf("%lld",&n);
	b=(sqrt(1+24*n)-1)/6;
	a=3-n%3;
	printf("%lld\n",a>b?0:(b-a)/3+1);
	return 0;
}

#include <stdio.h>

int main(void)
{
	unsigned long long int ar[1000000],n;
	int i,num=0;
	ar[1]=5;
	ar[2]=7;
	for(i=3;i<1000000;i++)
		{
		ar[i]=ar[i-1]+3*i-1;
		//printf("%llu ",ar[i]);
		}
	scanf("%llu",&n);
	if(n==2)
		{
		printf("1");
		return 0;
		}
	i=1;
	while(ar[i]<=n)
		{
			if((n-ar[i])%3==0)
				num++;
			i++;
		}
	printf("%d",num);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
typedef long long int ll;
int main()
{
    ll n,ans=0;
    scanf("%lld",&n);
    ll min=2,compt=5;
    ll k=2;
    while(n>=min)
    {
        if(n%3==k) ans++;
        min+=compt;
        compt+=3;
        if(k>0)k--;
        else k=2;
    }
    printf("%lld",ans);
    return 0;
}

#include <stdio.h>

typedef long long LL_t;

int main()

{
    LL_t h, N, Ans, F, E;
    scanf("%I64d", &N);
    h = 1;
    Ans = 0;
    while(1) {
        F = h * 2 + h * (h - 1) / 2 * 3;
        if(F > N) {
            break;
        }
        E = N - F;
        if(E % 3 == 0) {
            ++Ans;
        }
        ++h;
    }
    printf("%I64d\n", Ans);
    return 0;
}

#include<stdio.h>
int main()
{
    long long int n,i,count=0;
    scanf("%I64d",&n);
    for(i=1;3*i*(i-1)/2+2*(i)<=n;i++)
    {
        if((n-2*i)%3==0)

        {
            count++;
        }
    }
    printf("%I64d\n",count);
    return(0);
}

#include<stdio.h>
typedef long long ll;
int main()
{
	ll n,i;
	int ans=0;
	scanf("%I64d",&n);
	for(i=1;i<n;i++)
	{
		if(1ll*i*(3*i+1)/2>n)
			break;
		else
		{
			if((n-1ll*i*(3*i+1)/2)%3==0)
				ans++;
		}
	}
	printf("%d",ans);
}

#include<stdio.h>
int main(){
    long long a,b=0,c,d,i,j,level,x,cards,n,t;
    scanf("%lld",&n);
    for(level=1000000;level>0;level--){
        x=(level*(level+1))/2-level;
        cards=(3*x+2*level);
        if(cards<=n){
            b=level;
            break;
        }
    }
//  printf("%lld\n",b);
    if(n%3==2){
        a=(b+2)/3;
    }else if(n%3==1){
        a=(b+1)/3;
    }else{
        a=b/3;
    }
    printf("%lld\n",a);
    return 0;
}

 #include<stdio.h>
 int main()
  {
    long long int t,n,i,count=0,rem;
    scanf("%I64d",&n);
    t=n%3;
    t=3-t;
    for(i=t;3*i*(i+1)/2<=n+i;i+=3)
    {
    count++;
    }
    printf("%I64d\n",count);
    return 0;
  }

#include<stdio.h>
int main() {
	long long int i=0,j=2,k,l,n,m;
	scanf("%lld",&n);
	for(;n-j>=0;j+=3) {n-=j;if(n%3==0)i++;}
	printf("%lld\n",i);
	return 0;
}

#include<stdio.h>

int main()
{
    long long n;
    scanf("%lld",&n);
    long long count = 0,check=2,var=2,iter = 1;
    while(check<=n)
    {
        if((n+iter)%3==0)
        {
            count++;
            //printf("%lld",iter);
        }
        var = var+3;
        check = check + var;
        //printf("%lld\n",check);
        //printf("%lld\n",iter);
        iter++;
        //printf("%lld\n",iter);
    }
    printf("%lld",count);
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    long long int n,i,s,j,sum=0;
    while(~scanf("%I64d",&n))
   {
   	sum=0;
    s=2;
    i=1;
    while(s<=n)
    {
    	i++;
    	s=i*(i+1)+i*(i-1)/2;
    }
    for(j=1;j<i;j++)
    {
    	if((n+j)%3==0)
    	sum++;
    }
    printf("%I64d\n",sum);
   }
}

#include<stdio.h>
int main()
{
	long long int n,count=0,t,i,q,sum;
	scanf("%lld",&n);
	t=n/5;
	for(i=1;i<t+2;i+=0)
	{
		if((n+i)%3==0)
		{
			sum=((i)*(i+1))/2;
			q=(n+i)/3;
			if(q>=sum)
				count++;
			else
				break;
			i+=3;
		}
		else
			i++;
	}
	printf("%lld\n",count);
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long k=0,n;
	while(scanf("%lld",&n)!=EOF)
	{
		k=0;
		for(long long i=sqrt(n);i>=1;i--)
		{
			if((n-(3*i*i+i)/2)%3==0&&(3*i*i+i)/2<=n)
			k++;
		}
		printf("%lld\n",k);
	}
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void)
{
	long long p,n,ans;
	while(scanf("%I64d",&n)==1)
	{
		if((n<=1)||(n==4))
		{
			printf("0\n");
		}
		else
		{
			p=(long long)((sqrt(24*n+1)-1)/6);
			if(n%3==0)
			{
				ans=p/3;
				printf("%I64d\n",ans);
			}
			else if(n%3==1)
			{
				ans=(p-2)/3+1;
				printf("%I64d\n",ans);
			}
			else
			{
				ans=(p-1)/3+1;
				printf("%I64d\n",ans);
			}
		}
	}
	return 0;
}

#include <stdio.h>

int main(void)
{
	long long int n;
	long long int b;
	int i;
	int c;

	scanf("%I64d", &n);

	c = 0;
	for(i = 1, b = 2; b <= n; i ++, b += 3 * (long long)i - 1)
	{
		if((n - b) % 3 == 0)
		{
			//printf("%d\n", i);
			c ++;
		}
	}

	printf("%d\n", c);

	return 0;
}

#include <stdio.h>
long long x(int n)
{
long long   i, sum=0,s;
  for (i=1;i<=n;i++)
     sum+=i;
s=sum*3+n*2;
return s;
}
int main()
{
  long long n,i,s=0,k;
  scanf("%I64d",&k);
  for (i=1;i<1000000;i++)
  {
    if ((k+i)%3==0&&(3*i*i+i)/2<=k) s++;
  }
  printf("%I64d\n",s);
}

#include<stdio.h>
int main()
{
	int n,t;
	double k;
	scanf("%d",&n);
	for(k=1;k<n;k++)
	{
		if(n<k/2*k*3+k/2)
		{
			break;
		}
	}
	t=k;
	int c=0;
	t=t-1;
	while(t)
	{
		if((n+t)%3==0)
		{
			c++;
		}
		t--;
	}
	printf("%d",c);
	return 0;
}

#include<stdio.h>
int main()
{
	long n,t;
	double k;
	scanf("%ld",&n);
	for(k=1;k<n;k++)
	{
		if(n<k/2*k*3+k/2)
		{
			break;
		}
	}
	t=k;
	long c=0;
	t=t-1;
	while(t)
	{
		if((n+t)%3==0)
		{
			c++;
		}
		t--;
	}
	printf("%ld",c);
	return 0;
}

#include<stdio.h>
int main()
{
	long long n,i;
	while(scanf("%lld",&n)!=EOF)
	{
		int s=0,m,t,j,c,d=0;
		for(i=1;i*i<=n;i++)
		{
			c=(n-2*i);
			t=c/3;
			d+=i-1;
			if(c%3==0&&t>=d)
			{
				s++;
			}
		}

			printf("%d\n",s);
	}
}

#include<stdio.h>
int fact(int x);
int main()
{
	long long n,i;
	while(scanf("%lld",&n)!=EOF)
	{
		int s=0,m,t,j,c,d;
		for(i=1;i<=10;i++)
		{
			c=(n-2*i);
			t=c/3;
			if(c%3==0&&t>=fact(i))
			{
				s++;
			}
		}

			printf("%d\n",s);
	}
}
int fact(int x)
{
	int i,s=0;
	for(i=1;i<x;i++)
	{
		s+=i;
	}
	return s;
}

#include <stdio.h>
#define ll long long
ll arr[3000005];
int main()
{

    int i;
    arr[0]=0;
    arr[1]=2;

    ll a=2;
    for(i=2;i<3000005;i++)
    {
        a+=((i-1)*3+2);
        arr[i]=a;
    }

    ll n;
    scanf("%lld",&n);
    ll ans=0;
    for(i=1;i<300005;i++)
    {
        int flag=0;
        if(n>=arr[i])
        {
            ll diff=n-arr[i];

            if(diff%3==0)
            {
                //printf("i=%d\n",i);
                ans+=1;
            }
        }
    }

    printf("%lld\n",ans);

}

#include<stdio.h>
#include<math.h>
typedef long long ll;
int main()
{
	ll n;
	scanf("%lld",&n);
	ll maxi=sqrt(n);
	int is=0;
	for(ll i=maxi;i>=1;i--)
	{
		if(3*(i+i*i)%2==0)
		{
			if(3*(i+i*i)/2+2*(i+1)<=n)
			{
				if((n-(3*(i+i*i)/2+2*(i+1)))%3==0)
				{
					is++;
				}
			}
		}
	}
	printf("%d",is);
}

#include <stdio.h>
#define LL long long
int main()
{
    LL n;
    int ans=0;
    scanf("%I64d",&n);
    int rem=n%3;
    LL q=n/3;
    LL start;
    if(rem==0)
    {
        start=3;
    }
    else if(rem==1)
    {
        start=2;
    }
    else
    {
        start=4;
        q++;
    }
    LL lim=(start*(start+1))/2;
    while((q+ans+1)>=lim)
    {
        ans++;
        start+=3;
        lim=(start*(start+1))/2;
    }
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
int main()
{
  long long int n,i,t[3]={0},j,s;
   scanf("%I64d",&n);
   for(i=2,s=0,j=0;s<n;i+=3)
	{s+=i;
         t[s%3]++;
        }
    printf("%I64d\n",t[n%3]);

return 0;
}

#include<stdio.h>
int main()
{
  long long int n;
   scanf("%I64d",&n);
   if(n==1 ||n==3 || n==4 || n==6 || n==9 || n==12)
	printf("0\n");
   else
	printf("1\n");
return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int n,a,b;
	scanf("%d",&n);
	b=(sqrt(1+24*n)-1)/6;
	a=3-n%3;
	printf("%d\n",a>b?0:(b-a)/3+1);
	return 0;
}

#include <stdio.h>

int main(void)
{
	unsigned long long int ar[1000000],n;
	int i,num=0;
	ar[1]=5;
	ar[2]=7;
	for(i=3;i<1000000;i++)
		{
		ar[i]=ar[i-1]+3*i-1;
		//printf("%llu ",ar[i]);
		}
	scanf("%llu",&n);
	i=1;
	while(ar[i]<=n)
		{
			if((n-ar[i])%3==0)
				num++;
			i++;
		}
	printf("%d",num);
	return 0;
}

#include<stdio.h>
int main()
{
	long long n;
	scanf("%lld",&n);
	long long l=1,r=n/2+1,mid,ser,u;
	if (n==2) {printf("1\n");return 0;}
	while (l+1<r)
	{
		mid=l+(r-l)/2;
		ser=(n-mid*2)/3;
		//printf("%lld %lld\n",l,r);
		if ( mid%2==0 ) u=mid/2*(mid-1);else u=(mid-1)/2*mid;
		if (mid*2+ser*3==n&&ser>=u) l=mid;
		else r=mid;
	}
	if ((l==1)&&!(mid*2+ser*3==n&&ser>=u)) {printf("0\n");return 0;}
	else {l=l/3+1;printf("%lld\n",l);return 0;}
}

#include<stdlib.h>
#include<stdio.h>
typedef long long ll;
ll n,ans=0;
int main()
{
	scanf("%LLd",&n);
	ll right=1000000000,left=0,mid;
	while(left<=right)
	{
		mid=(left+right)/2;
		if(2*n-(3*mid-1)*(3*mid+1)<6*mid+4)
			right=mid-1;
		else
		{
			ans=mid;
			left=mid+1;
		}
	}
	printf("%LLd",ans);
}

#include<stdlib.h>
#include<stdio.h>
typedef long long ll;
ll n,ans=0;
int main()
{
	scanf("%LLd",&n);
	ll right=10000000000,left=0,mid;
	while(left<=right)
	{
		mid=(left+right)/2;
			if(2*n-3*(mid+1)*mid<(mid+1)*4)
			{
				 right=mid-1;
			}
		    else
		     {
                   ans=mid;
				   left=mid+1;
			 }
	}
	if((n-(3*(ans+1)*ans/2))%2!=0&&ans>0)
		ans--;
	printf("%LLd",ans);
}

#include<stdlib.h>
#include<stdio.h>
typedef long long ll;
ll n,ans=0;
int main()
{
	scanf("%LLd",&n);
	ll i,ans=0,x;
	for(i=1;i<n;i++)
	{
		x=n-(3*i+1)*i/2;
		if(x<0)
		  break;
		else{if(x%3==0) ans++;}
	}
	printf("%LLd",ans);
}

#include<stdlib.h>
#include<stdio.h>
typedef long long ll;
ll n,ans=0;
int main()
{
	scanf("%LLd",&n);
	ll right=1000000000,left=0,mid;
	while(left<=right)
	{
		mid=(left+right)/2;
		if(2*n-(3*mid+1)*mid<6*mid+4)
			right=mid-1;
		else
		{
			ans=mid;
			left=mid+1;
		}
	}
	printf("%LLd",ans);
}

#include<stdio.h>
int main() {
	long long int i=0,j=2,k,l,n,m;
	scanf("%lld",&n);
	for(;n-j>=0;j+=3,i++) n -= j;
	printf("%lld\n",n%3?0:i);
	return 0;
}

#include<stdio.h>
int main() {
	long long int i=0,j=2,k,l,n,m;
	scanf("%lld",&n);
	for(;n-j>=0;j+=3,i++) n -= j;
	printf("%lld\n",n%3?0:i-1);
	return 0;
}

#include<stdio.h>

int main()
{
    long long n;
    scanf("%lld",&n);
    long long count = 0,check=2,var=2,iter = 1;
    while(check<n)
    {
        if(n>check && ((n+iter)%3==0))
            count++;
        var = var+iter*3;
        check = check + var;
        iter++;
    }
    printf("%lld",count);
    return 0;
}

#include<stdio.h>

int main()
{
    long long n;
    scanf("%lld",&n);
    long long count = 0,check=2,var=2,iter = 1;
    while(check<n)
    {
        if(n>check && ((n+iter)%3==0))
            count++;
        var = var+3;
        check = check + var;
        iter++;
    }
    printf("%lld",count);
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    long long int n,i,s,j,sum=0;
    scanf("%I64d",&n);
    s=2;
    i=1;
    while(s<n)
    {
    	i++;
    	s=i*(i+1)+i*(i-1)/2;
    }
    for(j=1;j<i;j++)
    {
    	if((n+j)%3==0)
    	sum++;
    }
    printf("%I64d",sum);
}

#include<stdio.h>
int main()
{
	long int n,count=0,t,i,q,sum;
	scanf("%ld",&n);
	t=n/5;
	for(i=1;i<t+2;i++)
	{
		if((n+i)%3==0)
		{
			sum=((i)*(i+1))/2;
			q=(n+i)/3;
			if(q>=sum)
				count++;
		}
	}
	printf("%ld\n",count);
	return 0;
}

#include<stdio.h>
#include<math.h>
int n;
int main()
{
	while (scanf("%d",&n)!=EOF)
	{int k=0;
		for(int i=sqrt(n);i>=1;i--)
		{
			if((2*n-(3*i*i+i))%3==0)
			k++;
		}
		printf("%d\n",k);
	}
}

#include <stdio.h>
long long x(int n)
{
long long   i, sum=0,s;
  for (i=1;i<=n;i++)
     sum+=i;
s=(sum+n)*3;
return s;
}
int main()
{
  long long n,i,s;
  scanf("%I64d",&n);
  for (i=1;i<10000000;i++)
  {
    if (x(i)>n)
     {s=i;
     break;}
  }
  printf("%I64d\n",s-1);
}

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <math.h>
#include <windows.h>
int main()
{
	long long n,a[100005],i;
	scanf("%I64d",&n);
	for (i=1;i<=100005;i++)
	  {if((i-1)*i*3/2+2*i>n)
	    break;
	  }
	printf("%I64d\n",i-2);
}

#include <stdio.h>

int main(void)
{
	int n;
	int b;
	int i;
	int c;

	scanf("%d", &n);

	c = 0;
	for(i = 1, b = 2; b <= n; i ++, b += 3 * i - 1)
	{
		if((n - b) % 3 == 0)
			c ++;
	}

	printf("%d\n", c);

	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int n;
	scanf("%lld",&n);
	long long int m=(-1+sqrt(1+24*n))/6;
	int i=(3-n)%3;
	int j=m%3;
	int k=0;
	if(i<=j&&i!=0)
		k=1;
	printf("%lld",m/3+k);
	return 0;
}

#include<stdio.h>
#include<math.h>

void solve(long long int x)
{
    long long int n=(long long int)((sqrt(24*x + 1) - 1)/6.0);
    long long int ans=0,rem=x-(3*n*n+n)/2;
    if(n>1)
    {
        ans=1;
        while(n>1)
        {
            if((rem+2)%3==0)
            {
                ans++;
            }
            rem+=2;
            n--;
        }
    }
    printf("%lld",ans);
}
int main()
{
    long long int n;
    scanf("%lld",&n);
    solve(n);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long long int n,i,j,count=0;
    scanf("%lld",&n);

    j=sqrt(n);
    for(i=1;i<=j;i++)
    {
        if((n+i)%3==0)
            count++;
    }

    printf("%lld\n",count);

    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long long int n,i,j,count=0;
    scanf("%lld",&n);

    //j=sqrt(n);
    j = (1 + sqrt(1+24*n))/6;
    for(i=1;i<=j;i++)
    {
        if((n+i)%3==0)
            count++;
    }

    printf("%lld\n",count);

    return 0;
}

#include<stdio.h>
int main(){
	long long int i,sum,j,k,l,n,m,rem;
	scanf("%lld",&n);
	sum=2;
	m = 1;
	while(sum<n){
		m++;
		sum = (m*(3*m+1))/2;
	}
	if(sum==n)
		rem = sum;
	else
		rem = ((m-1)*(3*m-2))/2;
//	printf("%lld %lld %lld\n",m,sum,rem);
	if((n-rem)%3==0)
		if(m%3==0)
			printf("%lld\n",m/3);
		else
			printf("%lld\n",m/3+1);
	else if((n-rem)%3==2)
		if((m-2)%3==0)
			printf("%lld\n",(m-2)/3);
		else
			printf("%lld\n",(m-2)/3+1);
	else
		if((m-1)%3==0 || m-1==1)
			printf("%lld\n",(m-1)/3);
		else
			printf("%lld\n",(m-1)/3+1);
	return 0;
}

#include<stdio.h>
int main(){
	int i,j,k,l,n,m,a[10];
	for(i=0;i<10;i++)
		a[i]=0;
	for(i=0;i<6;i++){
		scanf("%d",&n);
		a[n]++;
	}
	int flag=0;
	for(i=1;i<10;i++){
		if(a[i]>=4){
			if(a[i]==4){
				for(j=1;j<10;j++)
					if(a[j]==2){
						flag=1;
						printf("Elephant\n");
					}
				if(flag==0)
					printf("Bear\n");
			}
			else if(a[i]==6)
				printf("Elephant\n");
			else
				printf("Bear\n");
			flag=1;
		}
	}
	if(flag==0){
		printf("Alien\n");
	}
	return 0;
}

#include<stdio.h>
int main(){
	long long int i,sum,j,k,l,n,m,rem;
	scanf("%lld",&n);
	sum=2;
	m = 1;
	while(sum<n){
		m++;
		sum = (m*(3*m+1))/2;
	}
	if(sum==n)
		rem = sum;
	else
		rem = ((m-1)*(3*m-2))/2;
//	printf("%lld %lld %lld\n",m,sum,rem);
	if((n-rem)%3==0)
		if(m%3==0)
			printf("%lld\n",m/3);
		else
			printf("%lld\n",m/3+1);
	else if((n-rem)%3==2)
		printf("%lld\n",(m-2)/3);
	else
		printf("%lld\n",m/3);
	return 0;
}

#include<stdio.h>
int main(){
	long long int sum,rem,i,j,k,l,n,m;
	scanf("%lld",&n);
	sum=0;
	m=1;
	if(n==1)
		printf("0\n");
	else{
		while(sum<=n){
			sum = (m*(3*m+1))/2;
			m++;
		}
		printf("%lld\n",m-3);
	}
	return 0;
}

#include<stdio.h>
int main(){
	long long int i,sum,j,k,l,n,m,rem;
	scanf("%lld",&n);
	sum=2;
	m = 1;
	while(sum<n){
		m++;
		sum = (m*(3*m+1))/2;
	}
	if(sum==n)
		rem = sum;
	else
		rem = ((m-1)*(3*m-2))/2;
//	printf("%lld %lld %lld\n",m,sum,rem);
	if((n-rem)%3==0)
		printf("%lld\n",m/3);
	else if((n-rem)%3==2)
		printf("%lld\n",(m-2)/3);
	else
		printf("%lld\n",(m-1)/3);
	return 0;
}

#include<stdio.h>
int main(){
	long long int sum,rem,i,j,k,l,n,m;
	scanf("%lld",&n);
	sum=0;
	m=1;
	while(sum<=n){
		sum = (m*(3*m+1))/2;
		m++;
	}
	printf("%lld\n",m-2);
	return 0;
}

#include<stdio.h>
int main(){
	long long int i,sum,j,k,l,n,m,rem;
	scanf("%lld",&n);
	sum=2;
	m = 1;
	while(sum<n){
		m++;
		sum = (m*(3*m+1))/2;
	}
	if(sum==n)
		rem = sum;
	else
		rem = ((m-1)*(3*m-2))/2;
//	printf("%lld %lld %lld\n",m,sum,rem);
	if((n-rem)%3==0)
		if(m%3==0)
			printf("%lld\n",m/3);
		else
			printf("%lld\n",m/3+1);
	else if((n-rem)%3==2)
		if((m-2)%3==0)
			printf("%lld\n",(m-2)/3);
		else
			printf("%lld\n",(m-2)/3+1);
	else
		if((m-1)%3==0)
			printf("%lld\n",(m-1)/3);
		else
			printf("%lld\n",(m-1)/3+1);
	return 0;
}

#include<stdio.h>
int main(){
	long long int last,sum=2,i,j,k,l,n,m,rem;
	scanf("%lld",&n);
	m = 1;
	rem = 5;
	while(sum<n){
		m++;
		last = sum;
		sum = sum + rem;
		rem = rem + 3;
	}
//	printf("%lld %lld %lld\n",m,sum,last);
	if(sum==n){
		if(m%3==0)
			printf("%lld\n",m/3);
		else if(m%3==1)
			printf("%lld\n",m/3+1);
		else
			printf("%lld\n",m/3+1);
	}
	else{
		m--;
		if((n-last)%3==0){
			if(m%3==0)
				printf("%lld\n",m/3);
			else if(m%3==1)
				printf("%lld\n",(m/3)+1);
			else
				printf("%lld\n",(m/3)+1);
		}
		else if((n-last)%3==1){
			if(m%3==0)
				printf("%lld\n",(m)/3);
			else if(m%3==1)
				if(m>1)
					printf("%lld\n",m/3+1);
				else
					printf("0\n");
			else
				printf("%lld\n",m/3+1);
		}
		else{
			if(m%3==0)
				printf("%lld\n",m/3);
			else if(m%3==1)
				printf("%lld\n",(m-1)/3);
			else
				printf("%lld\n",(m-2)/3);
		}
	}
	return 0;
}

#include<stdio.h>
long long add(long long x);
int main(void)
{
	long long m;
	scanf("%lld",&m);
	int min=0,max=4000000;
	int mid;
	while(min<=max)
	{
		mid=(min+max)/2;
		if(3*add(mid)+2*mid>m)
		     max=mid-1;
        else
             min=mid+1;
	}
	int count=0;
	for(int i=1;i<max+5;i++)
	{
		if((m-i*2)%3==0&&(m-i*2)/3>add(i-1))
		    count++;
	}
	printf("%d\n",count);
	return 0;
}

long long add(long long x)
{
	long long ans=0;
	for(int i=1;i<=x;i++)
	    ans=ans+x;
	    return ans;
}

#include<stdio.h>
long long add(long long x);
int main(void)
{
	long long m;
	scanf("%lld",&m);
	int min=0,max=4000000;
	int mid;
	while(min<=max)
	{
		mid=(min+max)/2;
		if(3*add(mid)+2*mid>m)
		     max=mid-1;
        else
             min=mid+1;
	}
	int count=0;
	for(int i=1;i<max+5;i++)
	{
		if((m-i*2)%3==0&&(m-i*2)/3>=add(i-1))
		    count++;
	}
	printf("%d\n",count);
	return 0;
}

long long add(long long x)
{
	long long ans=0;
	for(int i=1;i<=x;i++)
	    ans=ans+x;
	    return ans;
}

#include<stdio.h>
#include<math.h>
typedef long long ll;
int main()
{
	ll n;
	scanf("%lld",&n);
	ll maxi=sqrt(n);
	int is=0;
	for(ll i=maxi;i>=1;i--)
	{
		if(3*(i+i*i)%2==0)
		{
			if(3*(i+i*i)/2+2*(i+1)<=n)
			{
				if((n-(3*(i+i*i)/2+2*(i+1)))%3==0)
				{
					printf("%lld",i);
					is=1;
					break;
				}
			}
		}
	}
	if(is==0)
	{
		printf("0");
	}
}


#include <stdio.h>
#include <stdlib.h>

typedef struct {
     int m;
     int v;
     int i;
} lemmings;

int cmp(const void *a, const void *b)
{
     if (((lemmings *)a)->m != ((lemmings *)b)->m) {
	  return ((lemmings *)a)->m - ((lemmings *)b)->m;
     } else {
	  return ((lemmings *)a)->v - ((lemmings *)b)->v;
     }
}

int main()
{
     int n, k, h, i, j;
     double l, r, m;
     lemmings a[100000];
     int b[100000], c[100000];

     scanf("%d %d %d", &n, &k, &h);

     for (i = 0; i < n; i++) scanf("%d", &a[i].m);
     for (i = 0; i < n; i++) scanf("%d", &a[i].v);

     for (i = 0; i < n; i++) a[i].i = i + 1;

     qsort(a, n, sizeof(lemmings), cmp);

     l = 0, r = 1e18, m = (l + r) / 2;

     for (i = 0; i < 500; i++) {
	  int p = 0;

	  for (j = 0; j < n && p < k; j++) {
	       if ((double)(p + 1) * h / a[j].v <= m) {
		    b[p++] = a[j].i;
	       }
	  }

	  if (p >= k) {
	       r = m;
	       m = (l + r) / 2;

	       for (j = 0; j < k; j++) c[j] = b[j];
	  } else {
	       l = m;
	       m = (l + r) / 2;
	  }
     }

     for (i = 0; i < k; i++) {
	  if (i > 0) putchar(' ');

	  printf("%d", c[i]);
     }

     puts("");

     return 0;
}

#include <stdio.h>
#include <stdlib.h>

typedef struct {
     int m;
     int v;
     int i;
} lemmings;

int cmp(const void *a, const void *b)
{
     if (((lemmings *)a)->m != ((lemmings *)b)->m) {
	  return ((lemmings *)a)->m - ((lemmings *)b)->m;
     } else {
	  return ((lemmings *)a)->v - ((lemmings *)b)->v;
     }
}

int main()
{
     int n, k, h, c, i, j;
     double l, r, m;
     lemmings a[100000];

     scanf("%d %d %d", &n, &k, &h);

     for (i = 0; i < n; i++) scanf("%d", &a[i].m);
     for (i = 0; i < n; i++) scanf("%d", &a[i].v);

     for (i = 0; i < n; i++) a[i].i = i + 1;

     qsort(a, n, sizeof(lemmings), cmp);

     l = 0, r = 1e9, m = (l + r) / 2;

     for (i = 0; i < 500; i++) {
	  c = 0;

	  for (j = 0; j < n; j++) {
	       if ((double)(c + 1) * h / a[j].v <= m) c++;
	  }

	  if (c >= k) {
	       r = m;
	       m = (l + r) / 2;
	  } else {
	       l = m;
	       m = (l + r) / 2;
	  }
     }

     for (i = 0, c = 0; i < n && c < k; i++) {
	  if ((double)(c + 1) * h / a[i].v <= r) {
	       if (c > 0) putchar(' ');

	       printf("%d", a[i].i);

	       c++;
	  }
     }

     puts("");

     return 0;
}

#include <stdio.h>
#include <stdlib.h>

typedef struct {
     int m;
     int v;
     int i;
} lemmings;

int cmp(const void *a, const void *b)
{
     if (((lemmings *)a)->m != ((lemmings *)b)->m) {
	  return ((lemmings *)a)->m - ((lemmings *)b)->m;
     } else {
	  return ((lemmings *)a)->v - ((lemmings *)b)->v;
     }
}

int main()
{
     int n, k, h, c, i, j;
     double l, r, m;
     lemmings a[100000];

     scanf("%d %d %d", &n, &k, &h);

     for (i = 0; i < n; i++) scanf("%d", &a[i].m);
     for (i = 0; i < n; i++) scanf("%d", &a[i].v);

     for (i = 0; i < n; i++) a[i].i = i + 1;

     qsort(a, n, sizeof(lemmings), cmp);

     l = 0, r = 1e18, m = (l + r) / 2;

     for (i = 0; i < 100; i++) {
	  c = 0;

	  for (j = 0; j < n; j++) {
	       if ((double)(c + 1) * h / a[j].v <= m) c++;
	  }

	  if (c >= k) {
	       r = m;
	       m = (l + r) / 2;
	  } else {
	       l = m;
	       m = (l + r) / 2;
	  }
     }

     for (i = 0, c = 0; i < n && c < k; i++) {
	  if ((double)(c + 1) * h / a[i].v <= r) {
	       if (c > 0) putchar(' ');

	       printf("%d", a[i].i);

	       c++;
	  }
     }

     puts("");

     return 0;
}

#include <stdio.h>
#include <stdlib.h>

typedef struct {
     int m;
     int v;
     int i;
} lemmings;

int cmp(const void *a, const void *b)
{
     if (((lemmings *)a)->m != ((lemmings *)b)->m) {
	  return ((lemmings *)a)->m - ((lemmings *)b)->m;
     } else {
	  return ((lemmings *)a)->v - ((lemmings *)b)->v;
     }
}

int main()
{
     int n, k, h, i, j;
     double l, r, m;
     lemmings a[100000];
     int b[100000], c[100000];

     scanf("%d %d %d", &n, &k, &h);

     for (i = 0; i < n; i++) scanf("%d", &a[i].m);
     for (i = 0; i < n; i++) scanf("%d", &a[i].v);

     for (i = 0; i < n; i++) a[i].i = i + 1;

     qsort(a, n, sizeof(lemmings), cmp);

     l = 0, r = 1e18, m = (l + r) / 2;

     for (i = 0; i < 100; i++) {
	  int p = 0;

	  for (j = 0; j < n && p < k; j++) {
	       if ((double)(p + 1) * h / a[j].v <= m) {
		    b[p++] = a[j].i;
	       }
	  }

	  if (p >= k) {
	       r = m;
	       m = (l + r) / 2;

	       for (j = 0; j < k; j++) c[j] = b[j];
	  } else {
	       l = m;
	       m = (l + r) / 2;
	  }
     }

     for (i = 0; i < k; i++) {
	  if (i > 0) putchar(' ');

	  printf("%d", c[i]);
     }

     puts("");

     return 0;
}

#include <stdio.h>
#include <stdlib.h>

typedef struct {
     int m;
     int v;
     int i;
} lemmings;

int cmp(const void *a, const void *b)
{
     if (((lemmings *)a)->m != ((lemmings *)b)->m) {
	  return ((lemmings *)a)->m - ((lemmings *)b)->m;
     } else {
	  return ((lemmings *)a)->v - ((lemmings *)b)->v;
     }
}

int main()
{
     int n, k, h, c, i, j;
     double l, r, m;
     lemmings a[100000];

     scanf("%d %d %d", &n, &k, &h);

     for (i = 0; i < n; i++) scanf("%d", &a[i].m);
     for (i = 0; i < n; i++) scanf("%d", &a[i].v);

     for (i = 0; i < n; i++) a[i].i = i + 1;

     qsort(a, n, sizeof(lemmings), cmp);

     l = 0, r = 1e9, m = (l + r) / 2;

     for (i = 0; i < 100; i++) {
	  c = 0;

	  for (j = 0; j < n; j++) {
	       if ((double)(c + 1) * h / a[j].v <= m) c++;
	  }

	  if (c >= k) {
	       r = m;
	       m = (l + r) / 2;
	  } else {
	       l = m;
	       m = (l + r) / 2;
	  }
     }

     for (i = 0, c = 0; i < n && c < k; i++) {
	  if ((double)(c + 1) * h / a[i].v <= r) {
	       if (c > 0) putchar(' ');

	       printf("%d", a[i].i);

	       c++;
	  }
     }

     puts("");

     return 0;
}