#include<bits/stdc++.h>
#define LL long long
#define ull unsigned long long
#define F(i,j,k) for(int i=(j);i<=(k);i++)
#define DF(i,j,k) for(int i=(j);i>=(k);i--)
#define P pair
#define dui priority_queue
using namespace std;
template<typename T>inline void read(T &n){
    T w=1;n=0;char ch=getchar();
    while(!isdigit(ch)&&ch!=EOF){if(ch=='-')w=-1;ch=getchar();}
    while(isdigit(ch)&&ch!=EOF){n=(n<<1)+(n<<3)+(ch^48);ch=getchar();}
    n*=w;
}
template<typename T>inline void write(T x){
    ull y=0;
    T l=0;
    if(x<0){x=-x;putchar('-');}
    if(!x){putchar(48);return;}
    while(x){y=y*10+x%10;x/=10;l++;}
    while(l){putchar(y%10+48);y/=10;l--;}
}
template<typename T>inline void writeln(T x){
    write(x);
    puts("");
}
template<typename T>inline void writes(T x){
    write(x);
    putchar(' ');
}
template<typename T>inline void checkmax(T &a,T b){a=a>b?a:b;}
template<typename T>inline void checkmin(T &a,T b){a=a<b?a:b;}
LL f[1000100],F[6];
const LL ten[6]={1,10,100,1000,10000,100000};
const LL c[10]={0,0,0,1,0,0,2,0,0,3};
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	LL K;read(K);K--;
	F(i,0,5)read(F[i]);
	memset(f,-0x7f,sizeof(f));
	f[0]=0;
	F(i,0,5){
		LL mx=K*3,g=1;
		while(mx>0){
			LL v,w;
			if(mx-g<0){v=mx*ten[i]*3;w=mx*F[i];}
			else {v=g*ten[i]*3;w=g*F[i];}
			mx-=g;
			DF(j,999999,1){if(j-v<0)break;checkmax(f[j],f[j-v]+w);}
			g<<=1;
		}
	}
	F(i,0,5)
		DF(j,999999,1)
			F(k,1,9){
				if(j-ten[i]*k<0)break;
				checkmax(f[j],f[j-ten[i]*k]+F[i]*c[k]);
			}
	int q;read(q);
	F(i,1,q){int x;read(x);writeln(f[x]);}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v)     v.begin(),v.end()
//#define   for(i,a,b)  for(ll i=a;i<b;i++)

int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
vector<double>v;
int a,b;
cin>>a>>b;
  if(a==0 && b==0){
      cout<<"NO";return 0;
  }

    if(a==b || b==a+1 || a==b+1)cout<<"YES";
    else cout<<"NO";

}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char s[110];
char ans[110];

int main(){
    scanf("%s",s);
    int l = strlen(s);
    int id = 0;
    int flag = 1;
    ans[id++] = s[0];
    for(int i=1;i<l;i++){
        if(s[i] == 'd'){
            if(i+2 < l-1 && s[i+1] == 'o' && s[i+2] == 't'){
                ans[id++] = '.';
                i = i + 2;
            }
            else ans[id++] = s[i];
        }
        else if(s[i] == 'a'){
            if(i+1 < l-1 && s[i+1] == 't' && flag == 1){
                ans[id++] = '@';
                flag = 0;
                i = i+1;
            }
            else ans[id++] = s[i];
        }
        else ans[id++] = s[i];
    }
    ans[id] = 0;
    printf("%s\n",ans);
    return 0;
}
/*2017-08-06 19:22:05.6*/


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
 ll n,m,k=1,l=1,sum=0,cnt=0,i=0,r,f=0,z=0;
string s,s1;
cin>>s;
while(i<s.size())
{
    if(s[i]=='a'&&s[i+1]=='t'&&i!=0&&i!=s.size()-2&&f==0)
    {
    //  s.erase(i,2);
      s.replace(i,2,"@");
      f=1;
    }
    if(s[i]=='d'&&s[i+1]=='o'&&s[i+2]=='t'&&i!=0&&i!=s.size()-3)
    {
      //  s.erase(i,3);
        s.replace(i,3,".");
    }
    i++;
}
cout<<s;
 return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main () {
	string s;
	getline(cin,s);
	bool at = false;
	int i;
	for (i = 0; i < s.size(); i++) {
		if (s[i] == '@') at = true;
	}

	cout<<s[0];
	i = 1;
	while (i<s.size()-3) {

		if (s[i] == 'd' && s[i+1] == 'o' && s[i+2] == 't' ) {
			cout<<'.';
			i+=3;
		} else {
		    if (! at && s[i] == 'a' && s[i+1] == 't') {
				cout<<'@';
				at = true;
				i+=2;
			} else {
				cout<<s[i];
				i++;
			}
		}
	}
	if (! at && i+1 < s.size()-1 && s[i] == 'a' && s[i+1] == 't') {
		cout<<'@';
		i+=2;
		cout<<s[i];
	} else {
	  cout<<s[i];
	  if (i+1<s.size()) cout << s[i+1];
	  if (i+2<s.size()) cout<<s[i+2];
	}
	return 0;
}


#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
    string s;cin>>s;
    string ans;ans+=s[0];
    int k=0;
    for(int i=1;i<s.size();i++)
    {
        string h=s.substr(i,3);
        string f=s.substr(i,2);
        if(h=="dot"&&i!=s.size()-3)
        {
            i+=2;
            ans+=char('.');
        }
        else if(f=="at"&&k==0)
        {
            k=1;
            i+=1;
            ans+=char('@');
        }
        else
            ans+=s[i];
    }
    cout<<ans;

}


#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
int i,flag=0,l;char a[101];
scanf("%s",&a);l=strlen(a);
cout<<a[0];
for(i=1;i<l;i++)
{
    if(a[i]=='d'&&a[i+1]=='o'&a[i+2]=='t'&&(i+2)!=(l-1))
    {
        i+=2;cout<<".";
    }
    else if(a[i]=='a'&&a[i+1]=='t'&&flag==0)
    {
        cout<<"@";i++;flag=1;
    }
    else cout<<a[i];
}
return 0;
}


#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int n, a[100];
string s;

int main()
{
    cin >> s;
    for(int i=0; i<100; i++) a[i]=0;
    for(int i=1; i<s.length()-1; i++)
        if(s.compare(i, 2, "at")==0) {
            s[i]='@'; a[i+1]=1; break; }
    for(int i=1; i<s.length()-3; i++)
        if(s.compare(i, 3, "dot")==0){
            s[i]='.'; a[i+1]=1; a[i+2]=1; }
    for(int i=0; i<s.length(); i++) if(a[i]==0) cout << s[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

string s;
string ans;

int main()
{
        cin >> s;
        bool t = false;
        s += "###";
        for(int i = 0; i < s.size() - 3; i++)
        {
                if(ans == "")
                {
                        ans += s[i];
                        continue;
                }
                if(s[i] == 'd' && s[i + 1] == 'o' && s[i + 2] == 't')
                {
                        ans += '.';
                        i += 2;
                }
                else if(s[i] == 'a' && s[i + 1] == 't' && t == false)
                {
                        t = true;
                        ans += '@';
                        i += 1;
                }
                else
                {
                        ans += s[i];
                }
        }
        if(ans[ans.size() - 1] == '.')
        {
                ans[ans.size() - 1] = 'd';
                ans += "ot";
        }
        cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <cstring>

using namespace std;
typedef long long ll;

int main(int argc, char** argv)
{
	int ans=-1;
	string s,res;
	cin>>s;
	res+=s[0];
	for(int i=1;i<s.size();i++)
	{
		if(s[i]=='a' && s[i+1]=='t' && ans==-1)
		{
			ans=1;res+='@';i++;
		}
		else if(s[i]=='d' && s[i+1]=='o' && s[i+2]=='t' && (i+2)!=s.size()-1)
		{
			res+='.';i+=2;
		}
		else res+=s[i];
	}
	for(int i=0;i<res.size();i++)
	{
		cout<<res[i];
	}
	return 0;
}


#include <iostream>
#include<string>
using namespace std;

int main()
{
    string x;
    bool aat=true;
    cin>>x;
    string y;
    y+=x[0];
    for(int i=1;i<x.length();i++)
    {
        if((x[i]=='a'&&x[i+1]=='t'&&aat==true&&i!=x.length()-2)){
                y+="@";aat=false;i++;
        }
        else if(x[i]=='d'&&x[i+1]=='o'&&x[i+2]=='t'&&i!=x.length()-3){
            y+=".";i+=2;
        }
        else
            y+=x[i];
    }

    cout<<y;
    return 0;
}


#include <bits\stdc++.h>
using namespace std;
#define rep(flag,a,b) for(int flag=(a);flag<=b;flag++)
#define Rep(flag,a,b) for(int flag=(a);flag>=b;flag--)
#define mem(flag) memset(flag,0,sizeof(flag))
#define Mem(flag) memset(flag,-1,sizeof(flag))
#define read(a) a=getInt()
#define En printf("\n")
#define P(a) printf("%d ",a)
#define Pn(a) printf("%d\n",a)
#define dbg(x) cout << (#x) << " = " << (x) << endl
#define W(a) while(a)
#define lowbit(x) (x&-x)
#define F .first
#define S .second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
const int MAX=12;
const int eps=1e-9;
inline const int getInt()  {
	int res=0,ch,flag=0;
    if((ch=getchar())=='-')
        flag=1;
    else if(ch>='0'&&ch<='9')
        res=ch-'0';
    while((ch=getchar())>='0'&&ch<='9')
        res=res*10+ch-'0';
    return flag?-res:res;
}
inline void printInt(int a) {
    if(a>9)
        printInt(a/10);
    putchar(a%10+'0');
}

#define DEBUG

char buf[200];
void sol() {
    int len=strlen(buf);
    int i=0; bool at=false;
    while(i<=len-1) {
        if(i==0||i==len-2||i==len-3) {
            if(!at&&i==len-3&&buf[i]=='a'&&buf[i+1]=='t') {
                printf("@"); i+=2; at=true;
            } else {
                printf("%c",buf[i]); i++;
            }
        } else {
            if(buf[i]=='a'&&!at) {
                if(i+1<=len-1&&buf[i+1]=='t') {
                    printf("@"); i+=2; at=true;
                } else {
                    printf("%c",buf[i]); i++;
                }
            } else if(buf[i]=='d') {
                if(i+2<=len-1&&buf[i+1]=='o'&&buf[i+2]=='t') {
                    printf("."); i+=3;
                } else {
                    printf("%c",buf[i]); i++;
                }
            } else {
                printf("%c",buf[i]); i++;
            }
        }
    }
}

int main() {
    #ifdef DEBUG
    //freopen("./input.txt","r",stdin);
    //freopen("./output.txt","w",stdout);
    int cases=1;
    while(cases--) {
    #endif
        //printf("%d %d\n",'@','a');
        scanf("%s",buf);
        sol();
    #ifdef DEBUG
    }
    #endif
    return 0;
}


#include<bits/stdc++.h>
using  namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) ((ll)(x).size())
#define init(x, a) memset(x, a, sizeof(x))
#define forr(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rfor(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef  long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef map<ll,ll> mll;
typedef unordered_map<ll,ll> umll;
//const ll mod = 1e6+3;
//const ld PI=3.14159265;
ll gcd(ll a,ll b) { return a?gcd(b%a,a):b;}

int main()
{
    fastio;
    int r=0,k=0;
    string s,ans="";
    cin>>s;
    ans+=s[0];
    forr(i,1,sz(s))
    {
        r=0;
        if(s[i]=='d'&& i+3<sz(s))
        {
            if(s[i+1]=='o' && s[i+2]=='t'){ans+='.';i+=2;r=1;}
        }
        if(s[i]=='a' && i+1<sz(s) && k==0)
        {
            if(s[i+1]=='t'){ans+='@';i+=1;r=1;k=1;}
        }
        if(r==0)
        {
            ans+=s[i];
        }
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#define ll long long int
#define e() cout << endl;
#define MA INT_MAX
#define MI INT_MIN
#define MOD 1000000007;
#define ppi pair <int,int>
#define scn(n) scanf("%d",&n)
#define vvi(n,m,x) vector <vector <int> > v(n,vector <int> (m,x));
#define cp(x,y) cout << "Case : " << x << " " << y << endl;
using namespace std;
int main()
{
	string s,x = "";
	bool ok = true;
	cin >> s;
	for(int i = 0;i < s.size();)
	{
		if(s.substr(i,3) == "dot")
			x += '.',i += 3;
		else if(s.substr(i,2) == "at" && ok && i)
			x += '@',i += 2,ok = false;
		else
			x += s[i],i++;
	}
	for(int i = 0;i < x.size();i++)
		if(i == 0 && x[i] == '.')
			cout << "dot";
		else if(i == 0 && x[i] == '@')
			cout << "at";
		else if(i == x.size() - 1 && x.back() == '@')
			cout << "at";
		else if(i == x.size() - 1 && x.back() == '.')
			cout << "dot";
		else
			cout << x[i];
	e();
	return 0;
}


/*
ID:wmj20041
TASK:
LANG:C++
*/
#include<functional>
#include<algorithm>
#include<exception>
#include<stdexcept>
#include<streambuf>
#include<iterator>
#include<string.h>
#include<stdlib.h>
#include<typeinfo>
#include<valarray>
#include<iostream>
#include<sstream>
#include<istream>
#include<stdio.h>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<ctype.h>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<cstring>
#include<numeric>
#include<ostream>
#include<cwctype>
#include<fstream>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cctype>
#include<string>
#include<vector>
#include<limits>
#include<locale>
#include<memory>
#include<cerrno>
#include<time.h>
#include<iosfwd>
#include<cfloat>
#include<cstdio>
#include<cwchar>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<ios>
#include<map>
#include<set>
#include<new>
#define ll long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define FILLBIG(a) FILL(a,0x7f)
#define ALL(a) (a).begin(),(a).end()
#define Inf ((int)0x7f7f7f7f)
#define Mod 1000000007
#define foreach(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define fi first
#define se second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
#define cddx(a) priority_queue<a >
#define cxdd(a) priority_queue<a,vector<a >,greater<a > >
#define deval(a) {cerr<<#a<<" = "<<a<<endl;}
#define dearr(be,en) {cerr<<#be;cerr<<" = {";for(auto i=be;i!=en;i++)cerr<<' '<<*i;cerr<<" }\n";}
#define reg register
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int uint;
typedef long long INT;
typedef long double ldouble;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;
const int INF=1e9+7;
using namespace std;
int n,m;
string s,t;
int prime(int x)
{
	if (x==1) return 0;
	for (int i=2;i*i<=x;i++)
	if (x%i==0) return 0;
	return 1;
}
int check(int x,int y)
{
	if (x>n||x<1||y>=m||y<0) return 0;
	return 1;
}
long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>s;
	int p=0;
	int f1=1,f2=1;
	t+=s[0];
	for (int i=1;i<s.size();)
	{
		if (i!=s.size()-2&&s[i]=='a'&&s[i+1]=='t'&&f1==1)
		{
			f1=0;
			t+='@';
			i+=2;
			continue;
		}
		if (i!=s.size()-3&&s[i]=='d'&&s[i+1]=='o'&&s[i+2]=='t')
		{
			t+='.';
			i+=3;
			continue;
		}
		t+=s[i];
		i++;
	}
	cout<<t;
	return 0;
}


//In the Name of God
/*4
92 31
0 7
31 0
7 141
*/
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
#include <fstream>
#include <cstring>
#include <cctype>
//#include <conio.h>
using namespace std;
set <char> S;
int n,d=0,ans=0,m;
int a[100010],b;
string str,s;
int main()
{
  string s,ans;
  cin>>s;
  bool y=false;
  for(int i=0;i<s.size();i++)
    {
      if(i>0 && s[i]=='a' && s[i+1]=='t' && i<s.size()-2 && y==false)
    ans+='@',i++,y=true;
      else if(i>0 && s[i]=='d' && s[i+1]=='o' && s[i+2]=='t' && i<s.size()-3)
    ans+='.',i+=2;
      else
    ans+=s[i];
    }
  cout<<ans<<endl;
  return 0;
}


#include <iostream>
#include <string>
using namespace std;

string s;

string f(){
	for (int i=1;i<s.size()-2;i++)
		if (s[i]=='a' && s[i+1]=='t') {
			s.erase(i, 2), s.insert(i, "@");
			break;
		}
	//if (s[i]=='a' && s[i+1]=='t') s.erase(i+1, 1), s[i] = '@';

	for (int i=1;i<s.size()-3;i++)
		if (s[i]=='d' && s[i+1]=='o' && s[i+2]=='t') s.erase(i, 3), s.insert(i, ".");

	return s;
}

int main(){
	while (cin >> s){
		cout << f() << endl;
	}
}


#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;

}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    int n=s.size();
    string s1;
    int i=1;
    s1.pb(s[0]);
    while(i<n){
        if(i<n-3&&s[i]=='d'&&s[i+1]=='o'&&s[i+2]=='t'){
            s1.pb('.');
            i+=3;
        }
        else{
            s1.pb(s[i]);
            i++;
        }
    }
    int m=s1.size();
    i=1;
    string s2;
    s2.pb(s1[0]);
    bool b=true;
    while(i<m){
        if(b&&i<m-2&&s1[i]=='a'&&s1[i+1]=='t'){
           s2.pb('@');
           i+=2;
           b=false;
        }
        else{
            s2.pb(s1[i]);
            i++;
        }
    }
    cout<<s2;
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s ;
    cin >> s ;

    char ch = s[0] ;

    s = s.substr ( 1 , s.size() - 1 )  ;

       s.replace( s.find("at") , 2 , "@" ) ;

    for ( int i = 1 ; i < s.size() ; i++ )
        if ( s.find ("dot") != -1 && s.find ("dot") != s.size() - 3 )
            s.replace ( s.find ("dot") , 3 , "." ) ;

    cout << ch + s ;
    return 0 ;
}


/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
#define sz(v) (int)v.size()
#define endl '\n'
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
const int N = 3e4+5;
const int mod = 1e9 + 7;

int32_t main()
{

  speed_cubing

  string s;
  cin>>s;

  string ans = "";
  bool flag = 0;

  for(int i=0;i<s.size();i++){

     if(i+2<(int)s.size()-1 && i!=0){

        string temp = s.substr(i,3);

        if(temp=="dot"){
          ans+='.';
          i = i+2;
          continue;
        }

        temp = s.substr(i,2);

        if(temp=="at" && !flag){
          ans+='@';
          i = i+1;
          flag = 1;
          continue;
        }

     }
     else if(i+1<(int)s.size()-1 && !flag && i!=0){

        string temp = s.substr(i,2);

        if(temp=="at" && !flag){
          ans+='@';
          i = i+1;
          flag = 1;
          continue;
        }

     }

     ans+=s[i];

  }

  cout<<ans;

  return 0;
}


//In the name of God
#include <iostream>
#include <string>
using namespace std;

string in, out;

int main(){
    cin >> in;
    int lng = in.length();
    out = "";
    out += in[0];
    bool at = false;
    int i = 1;
    while (i < lng){
        if (!at && i < lng - 2 && in[i] == 'a' && in[i+1] == 't'){
            out += "@";
            at = true;
            i++;
        }else if (i < lng - 3 && in.substr(i, 3) == "dot"){
            out += ".";
            i+=2;
        }else{
            out += in[i];
        }
        i++;
    }
    cout << out << endl;
    return 0;
}


#include<new>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<iostream>
#include<algorithm>
using namespace std;

bool judge;
string a,b;

int main()
{
    cin>>a;
    int i=0;
    while(i<a.size())
    {
            if(a[i]=='d'&&i!=0&&i!=a.size()-3)
            {
                         if(a[i+1]=='o'&&a[i+2]=='t')
                         {
                                 b+='.';
                                 i+=3;
continue;
                         }
                         else
                         {
                                 b+=a[i];
                                 i++;
                                 continue;
                         }
            }
            else
            {
                if(a[i]=='a'&&i!=0&&i!=a.size()-2)
                {
                             if(a[i+1]=='t'&&judge==false)
                             {
                                     b+='@';
                                     i+=2;
                                     judge=true;
                                     continue;
                             }
                             else
                             {
                                     b+=a[i];
                                     i++;
                                     continue;
                             }
                }
                else b+=a[i];
                i++;
            }
    }

    cout<<b<<endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main()
{string s;
int mark=0;
cin>>s;
for (int i=0;i<s.size();i++)
{if (i==0)
cout<<s[i];
else
if(s[i]=='d'&&s[i+1]=='o'&&s[i+2]=='t'&&i+2!=s.size()-1)
{
cout<<'.';
i+=2;
}
else
if (mark==0&&s[i]=='a'&&s[i+1]=='t'&&i+1!=s.size()-1)
{

cout<<'@';
mark++;
i++;
}
else
cout<<s[i];
}
return 0;
}


/* OmShantihari; Author: Sujan Mridha, CSE 5th batch, University of Barishal */
#define fast ios :: sync_with_stdio(false); cin.tie(0);
#define f(i,a,b) for(i=a;i<=b;i++)
#define r(i,a,b) for(i=a;i>=b;i--)
#define lli long long int
#include<bits/stdc++.h>
#define pb push_back
#define rs resize
#define S second
#define F first
#define all(v) v.begin(), v.end()
using namespace std;vector <lli> a,b,c;string s;
lli nn[300002]={0};
int main ()
{
    fast;
	lli i,j,l=1,k=0,n,m,f=0,ff,x=0,xx,y,p;
	cin>>s;
	l=s.size();
	cout<<s[0];
	f(i,1,l-3)
	{
		if (k==0 && s[i]=='a' && s[i+1]=='t')
		{
			k=1;
			l--;
			cout<<'@';
			i+=1;
		}
		else if (i<=l-3 && s[i]=='d' && s[i+1]=='o' && s[i+2]=='t')
		{
			cout<<".";
			i+=2;
		}
		else cout<<s[i];
	}
	if (k==1) f(i,i,l) cout<<s[i];
	else f(i,i,l-1) cout<<s[i];
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
string s,ans;
bool u=false;
bool chdot(int i)
{
    if(s[i]=='d'&&s[i+1]=='o'&&s[i+2]=='t')
        return true;
    return false;
}
bool chat(int i)
{
    if(s[i]=='a'&&s[i+1]=='t')
        return true;
    return false;
}
int main()
{
    cin>>s;
    for(int i=0;i<s.size();)
    {
        if(i!=0&&i+2!=s.size()-1&&s[i]=='d'&&chdot(i))
        {
            ans.push_back('.');
            i+=3;
            continue;
        }
        if(!u&&i!=0&&i+1!=s.size()-1&&s[i]=='a'&&chat(i))
        {
            ans.push_back('@');
            i+=2;
            u=true;
            continue;
        }
        ans.push_back(s[i]);
        i++;
    }
    for(int i=0;i<ans.size();i++)
        cout<<ans[i];
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define pp pop_back
#define fr freopen
#define fi first
#define se second
using namespace std;
ll i , j , k , m , n , c[3000] , d , e , l = 1 , r;
string a , b;
int main()
{
    ///freopen("gcm.in" , "r" , stdin);
    ///freopen("gcm.out" , "w" , stdout);
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    cin>>a;
    n = a.length();
    b = b + a[0];
    for(i = 1 ; i < n ; i ++)
    {
        if(i < n - 2 && a[i] == 'a' && a[i + 1] == 't' && l == 1)
            b = b + '@' , i ++ , l = 0;
        else if(i < n - 3 && a[i] == 'd' && a[i + 1] == 'o' && a[i + 2] == 't')
            b = b + '.' , i += 2;
        else
            b = b + a[i];
    }
    cout<<b;
    return 0;
}


#include<bits/stdc++.h>
#define test(t) for(cin>>t;t;--t)
#define rep(i,n) for(ll i=0;i<n;i++)
#define repr(i,k,n) for(ll i=k;i<n;i++)
#define repr_r(i,n) for(ll i=n-1;i>=0;i--)
#define pb push_back
#define f first
#define sec second
#define in cin>>
#define out cout<<
#define optimize ios_base::sync_with_stdio(0);cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll>pll;

string email ;

string solve() {
    // handle @
    ll at_pos = email.find("at", 1);
    if(at_pos != string::npos)
    email.replace(at_pos, 2, "@");
    // handle dot
    ll pos = email.find("dot", 1);
    while( pos != string::npos && email.size() != pos + 3) {
        email.replace(pos, 3, ".");
        pos = email.find("dot", 1);
    }
    return email;
}

int main(){
	optimize
    in email;
    out solve();
	return 0;
}


#include <bits/stdc++.h>
#define MIN -1
#define MAX 1e9+7
#define SMAX 2*(1e18)+7
#define all(a) a.begin (), a.end()
#define mk  make_pair
#define pb  push_back
#define F first
#define S second
#define tri(a)  (a*(a+1))/2
#define fixed(a, c)  fixed<<setprecision(c)<<a
#define mem(a, c) memset(a, c, sizeof a)
#define sub(a, b, c) a.substr(b, c)
#define rall(a) a.rbegin(), a.rend()
#define lower(a, c) lower_bound(a.begin (), a.end (), c);
#define upper(a, c) upper_bound(a.begin (), a.end (), c);
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI 3.14159265359
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef   long long int  ll;
typedef pair <int, int> ii;
typedef vector <ll> vll;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;
typedef priority_queue <ll, vector <ll>, greater <ll> > pq;
typedef double db;
int getint(string  s)
{
    int x=stoi(s);
    return x;
}
string getstring (int x)
{
    string lol=to_string(x);
    return lol;
}

bool ok(int x, int gg)
{
    return (x<=gg-1 and x>=0);
}
int X[4]= {1, 0, -1, 0};
int Y[4]= {0, 1, 0, -1};
/*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}
ll exponentMod(ll A, ll B, ll C)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;
    ll y;
    if (B % 2 == 0)
    {
        y = exponentMod(A, B / 2, C);
        y = (y * y) % C;
    }
    else
    {
        y = A % C;
        y = (y * exponentMod(A, B - 1, C) % C) % C;
    }
    return (ll)((y + C) % C);
}
bool ispal(string x)
{
    for(int i=0, j=x.size ()-1; i<x.size (); i++, j--)
    {
        if(i>j)break;
        if(x[j]!=x[i])return false;
    }
    return true;
}
//VIVA      EL       GG!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

int main()
{
    string s;
    while(cin>>s){
        string ans;
        int n=s.size ();
        ans+=s[0];
       // ans+=s[1];
       int sw=0;
        for(int i=1;i<n;i++){
            if(s[i]=='a' && s[i+1]=='t'){
                if(i+1==n-1){
                    ans+=s[i];
                    ans+=s[i+1];
                    i++;
                }else{
                if(!sw){
                i++;
                ans+='@';sw=1;
                }else {
                    ans+=s[i];ans+=s[i+1];
                    i++;
                }
                }
                continue;
            }
            if(s[i]=='d' && s[i+1]=='o' && s[i+2]=='t'){
                if(i+2==n-1){
                    ans+=s[i];
                    ans+=s[i+1];
                    ans+=s[i+2];
                    i+=2;
                }else{
                i+=2;
                ans+='.';
                }continue;
            }else ans+=s[i];
        }
        cout<<ans<<endl;
    }
}


#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
    string x;
    cin>>x;
    string y="";
    y+=x[0];
    bool stop=false;
    for(int i=1; i<x.length(); i++){
        if(x[i]=='a' && x[i+1]=='t' && i+1!=x.length() && x.length()-i>2 && stop==false ) {
                                                                                y+='@';
                                                                                i++;
                                                                                stop=true;
                                                                                }
        else if(x[i]=='d' && x[i+1]=='o' && x[i+2]=='t' && i+1!=x.length() && x.length()-i>3 ) {
                                                                                y+='.';
                                                                                i+=2;
                                                                                }
        else y+=x[i];
    }
    cout<<y;

return 0;
}


#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAX 100000000000000000
#define MOD 1000000007
#define files  freopen("OUTPUT.TXT","r",stdin);
#define PI 3.141592653589793238462
#define INF 1000000000
using namespace std;
int my_find(string s1,string s2,int start){
	for (int i=start;i<s1.size();i++){
		if (s1[i]==s2[0]){
			bool f=1;
			for (int j=i+1;j<i+s2.size();j++){
				if (s2[j-i]!=s1[j]) f=0;
			}
			if (f) return i;
		}
	}
	return -1;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string s1,s2,ans;
	bool findat=0;
	int pos;
	cin>>s1;
	pos=my_find(s1,"at",1);
	s2=s1.substr(0,pos)+'@'+s1.substr(pos+2);
	int i=my_find(s2,"dot",1),last=0;
	while(i!=-1&&i<s2.size()-3){
		ans+=s2.substr(last,i-last)+".";
		last=i+3;
		i=my_find(s2,"dot",last);
	}
	ans+=s2.substr(last);
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;

/* MATH */
bool isPrime(ull n)
{
    if (n <= 1)  return true;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;

    for (ull i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}

ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)
{
	if(k>n)return 0;
    ll res = 1;
    if ( k > n - k )
        k = n - k;
    for (int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}

//
/* MACROS */

#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define  deb(x)       cout << '>' << #x << ':' << x << endl;

void  solve()
{
	string s;
	cin>>s;
	bool at=0;
	int n=ln(s);
	cout<<s[0];
	int d1=0,d2=0;
	int done[n+1]={0};
	done[0]=true;
	fora(i,1,n-3)
	{
		done[i]=true;
		if(s[i]=='a'&&s[i+1]=='t'&&!at)
		{
			cout<<'@';
			at=1;
			done[i+1]=true;
			i++;
		}
		else if(s[i]=='d'&&s[i+1]=='o'&&s[i+2]=='t'&&(i!=n-3))
		{
			cout<<'.';
			done[i+1]=true;
			done[i+2]=true;
			i+=2;
		}
		else cout<<s[i];
	}
	forn(i,n)if(!done[i])cout<<s[i];
}

int main()
{

    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("op.txt", "w", stdout);
    #endif
    FastIO;
    ll t=1;
   	//cin>>t;
    while(t--)
    {
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    string ans;
    ans.push_back(s[0]);
    bool at = false;
    for(int i=1;i<s.size();){
        if(s.substr(i,3)=="dot"&&i+3!=s.size()){
            i+=3;
            ans.push_back('.');
        }else if(s.substr(i,2)=="at"&&!at&&i+2!=s.size()){
            i+=2;
            at = true;
            ans.push_back('@');
        }else{
            ans.push_back(s[i]);
            ++i;
        }
    }
    printf("%s",ans.c_str());
}


#include <bits/stdc++.h>
using namespace std;

int main(){
	int check=0;
	string a;
	getline(cin,a);
	for(int i=0;i<a.length();){
		if(a[i]=='d' && a[i+1]=='o' && a[i+2]=='t' && i+3!=a.length() && i!=0){
			cout<<'.';	i+=3;	continue;
		}
		if(a[i]=='a' && a[i+1]=='t' && i!=0 && check==0){
			cout<<'@';	i+=2;	check=1;	continue;
		}
		cout<<a[i];		i++;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef long long int ll;
typedef vector<vector<int>> Vii;
typedef vector<vector<long long>> Vll;
typedef vector<string> vs;
#define forn(i,a,b) for(i=a;i<b;i++)
#define rforn(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define srt(s) sort(s.begin(),s.end())
#define rev(s) reverse(s.begin(),s.end())
#define mine(v) min_element(v.begin(),v.end())
#define maxe(v) max_element(v.begin(),v.end())
#define all(v)  v.begin(),v.end()
#define inp(v); forn(ee,0,v.size())cin>>v[ee];
#define out(v); forn(ee,0,v.size())cout<<v[ee]<<" ";cout<<endl;
#define F first
#define S second
#define CC cout<<"....CHECK....";
#define EE cout<<endl;
//   for(auto it=mp.begin();it!=mp.end();it++)
//       {
//           cout<<it->F<<" ";
//       }
//     cout<<endl;

int main()
{
    ll n,m,i,j,k,cnt=0,sum=0,mn=INT_MAX,mx=INT_MIN,diff,ans,num,x,y,z,size,ee,ind;
    int flag=0,t=1;
    string s,str,s1,s2,s3;
    char ch;

  //  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    /*

            * * *           * * *          * * *          * * * * *
          *       *       *       *        *      *       *
         *               *         *       *       *      *
         *               *         *       *        *     *
         *               *         *       *        *     * * * * *
         *               *         *       *        *     *
         *               *         *       *       *      *
          *       *       *       *        *      *       *
            * * *           * * *          * * *          * * * * *

            Main code is written below.....
            © PA
     */

    // cin>>t;
   while(t--)
   {
    cin>>s;
    n=s.size();
    str="";
    str+=s[0];
    forn(i,1,n)
    {
        if(flag==0 && i<n-2)
        {
        s1=s.substr(i,2);
        if(s1=="at")
        {
            str+='@';
            i++;
            flag++;
            continue;
        }
        }

       s1=s.substr(i,3);
      if(s1=="dot" && i< n-3)
       {
        str+='.';
        i+=2;
        continue;
       }

       str+=s[i];

    }

    cout<<str;

   }
}


#include<bits/stdc++.h>
using namespace std;
string str;
string ans;
int n;
bool f=true;
int main(){
	cin>>str;
	n=str.length();
	int happy=19260817+19890604-20041023;
	for(int i=0;i<n;i++)if(str[i]=='a'&&str[i+1]=='t'&&f&&i!=0&&(i+1)!=n-1)putchar('@'),f=false,i+=1;else if(str[i]=='d'&&str[i+1]=='o'&&str[i+2]=='t'&&i!=0&&(i+2)!=n-1)putchar('.'),i+=2;else putchar(str[i]);
	return 0;
}


#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <math.h>
#include <stdlib.h>

typedef unsigned int        u32;
typedef int                 s32;
typedef float               fp32;
typedef double              fp64;
typedef __int64             s64;
typedef unsigned __int64    u64;

using namespace std;

const   s64     dx[4]       = {-1, 0, 1, 0};
const   s64     dy[4]       = {0, -1, 0, 1};

int main ()
{
    string email;
    cin>>email;
//  string email = "dotdotdotatdotdotat";

    for (int i = 1; i < (email.size() - 2); i++)
    {
        if ((email[i] == 'a') && (email[i + 1] == 't'))
        {
            email[i] = '@';
            email.erase(i + 1, 1);
            break;
        }
    }

    for (int i = 1; i < (email.size() - 3); i++)
    {
        if ((email[i] == 'd') && (email[i + 1] == 'o') && (email[i + 2] == 't'))
        {
            email[i] = '.';
            email.erase(i + 1, 2);
        }
    }

    cout<<email;

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<sstream>
using namespace std;
#define FOR(I,A,B) for(int I=(A);I<=(B);I++)
#define REP(I,N) for(int I=0;I<(N);I++)
#define ALL(X) (X).begin(),(X).end()
#define VAR(A,B) __typeof(B) A=B
#define FORE(I,X) for(VAR(I,(X).begin());I!=(X).end();I++)
#define F first
#define S second
#define INF 1000000007
#define PB push_back
#define MP make_pair
typedef pair<int,int> PII;
typedef long long LL;
char tab[134];
string imejl;

int main(){
	scanf("%s",tab);
	imejl=tab;
	for(int i=1;i<imejl.size()-1;i++){
		if (imejl[i]=='a' && imejl[i+1]=='t'){
			imejl[i]='@';
			break;
		}
	}
	for(int i=1;i<imejl.size()-3;i++){
		if (imejl[i]=='d' && imejl[i+1]=='o' && imejl[i+2]=='t'){
			imejl[i]='.';
		}
	}
	REP(i,imejl.size()){
		if (imejl[i]=='@'){
		       	printf("@");
			i++;
			continue;
		}
		if (imejl[i]=='.'){
			printf(".");
			i+=2;
			continue;
		}
		printf("%c",imejl[i]);
	}
	printf("\n");
}


#include <iostream>

using namespace std;

int main()
{
        string s; cin >> s;
        int n = s.size();
        int i = 0;
        bool _at = true, _dot = true;
        while (i<n)
        {
                if (s[i]=='a' && s[i+1]=='t' && _at && i!=0)
                {
                        cout << "@";
                        i+=2;
                        _at = false;
                        continue;
                }
                if (s[i]=='d' && s[i+1]=='o' && s[i+2]=='t' && i!=0 && i+2!=n-1)
                {
                        cout << ".";
                        i+=3;
                        continue;
                }
                else
                {
                        cout << s[i];
                        i++;
                }
        }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){string a;cin>>a;a.replace(a.find("at",1),2,"@");for(int i=a.find("dot",1);i<a.size()-3;i=a.find("dot",1)) a.replace(i,3,".");cout<<a;}


#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int i, l;
string s;

bool dot() {
    return (i+2) < (l-1) && s[i+1] == 'o' && s[i+2] == 't';
}

bool at() {
    return (i+1) < l && s[i+1] == 't';
}

int main() {
    //freopen("input.txt", "r", stdin);

    cin >> s;

    l = s.length();

    cout << s[0];

    bool f = false;

    for (i = 1; i < l;) {
        if (s[i] == 'a' && !f && at()) {
            cout << '@';
            f = true;
            i += 2;
            continue;
        }

        if (s[i] == 'd' && dot()) {
            cout << '.';
            i += 3;
            continue;
        }

        cout << s[i];
        i++;
    }

    return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <queue>
#include <set>
#include <stack>
using namespace std;

int main()
{
	int n,l,i,sign;
    char s[1000];
    cin>>s;
    l=strlen(s);
    cout<<s[0];
    sign=0;
    for(i=1;i<l;i++)
    {
        if(i!=l-3&&s[i]=='d'&&s[i+1]=='o'&&s[i+2]=='t')
        {
            cout<<".";
            i+=2;
        }
        else if(i!=l-2&&s[i]=='a'&&s[i+1]=='t'&&sign==0)
        {
            cout<<"@";
            i+=1;
            sign=1;
        }
        else cout<<s[i];
    }
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MAX 1e9
#define fr(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    string s; cin>>s;
    ll n=s.size(),f=0;
    string ans="";
    ans+=s[0];
    string dt="dot";
    for(int i=1;i<n;i++)
    {
        if(s.substr(i,3)=="dot"&&i+3!=n)
                        {
                                ans=ans+".";
                                i+=2;
                        }
        else if(s[i]=='a')
        {

           if(i+1<n-1 && s[i+1]=='t'&& f==0)
           {ans+='@';
              f=1;
               i++;
           }
           else
            ans+=s[i];

        }
        else ans+=s[i];
    }
    cout<<ans;
}


//%%%%%%%%%%%%
//%%%%lost%%%%
//%%%%%%%%%%%%

#include <iostream>
#include <ctime>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <iterator>
using namespace std;

typedef long long  int64;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef string ST;
typedef stringstream SS;

#define 				  Pf	printf
#define				  Sf	scanf
#define				  ep	1e-9
#define			CL(a, b)	memset(a, b, sizeof(a))
#define				SZ(a)	int((a).size())
#define				  pb	push_back
#define			  all(c)	(c).begin(), (c).end()
#define			tr(i, c)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	 present(x, c)	((c).find(x) != (c).end())                      // used for map and set. //
#define	cpresent(x, c)	(find(all(c),x) != (c).end())           // used for others like vector, list //
#define		 forn(i, n)	for(int i = 0; i < n; i++)
#define  forab(i, a, b)	for(int i = a; i <= b; i++)
#define	  rep(i, a, b)	for(int i = a; i>=b; i--)

int main()
{
  ST s, ret;
  bool at = false;
  cin >> s;

  int len = s.length();

  forn(i, len)
  {
	 if( s.substr(i, 2) == "at" && !at && i != 0 && i != len-2 )
	 {
		ret += '@';
		at = true;
		i++;
	 }
	 else if(s.substr(i, 3) == "dot" && i != 0 && i != len - 3)
	 {
		ret += '.';
		i+=2;
	 }
	 else
		ret += s[i];
  }

  cout << ret ;

  return 0;
}


#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
int read(){
	char c=getchar();
	int sum=0;
	while(c>'9'||c<'0')c=getchar();
	while(c<='9'&&c>='0')sum=sum*10+c-'a',c=getchar();
	return sum;
}
string s;
char t[105];
int pos=1;
bool flag;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>s;
	t[0]=s[0];
	int sz=s.size();
	s+=char(1);
	s+=char(1);
	s+=char(1);
	s+=char(1);
	for(int i=1;i<sz;){
		if(s[i]=='d'&&s[i+1]=='o'&&s[i+2]=='t'&&s[i+3]!=char(1)){
			t[pos++]='.';
			i+=3;
			continue;
		}
		if(s[i]=='a'&&s[i+1]=='t'&&!flag){
			t[pos++]='@';
			flag=1;
			i+=2;
			continue;
		}
		t[pos++]=s[i];
		i++;
	}
	t[pos]='\0';
	printf("%s",t);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <string>

int main()
{
	std::string s;
	std::cin>>s;

	s.replace(s.find("at",1),2,"@");

	while(true)
	{
		int n = s.find("dot",1);
		if(n == s.npos || n > s.length() - 4)
			break;
		s.replace(n,3,".");
	}

	std::cout << s;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e4+7;

char str[maxn];

int main()
{
    ///dotdotatadasdatdotatjkl
    while(~scanf("%s",str))
    {
        int len=strlen(str);
        int flag = 0;
        for(int i = 0; i < len; i ++ ) {
            if(str[i] == 'd'&&i!=0&&i!=len-3&&str[i+1] == 'o' &&str[i+2] == 't') {
                    printf(".");
                    i+=2;
            }
            else if(str[i]=='a'&&i!=0&&i!=len-2&&str[i+1]=='t'&&!flag){
                    printf("@");
                    flag = 1;
                    i++;
            }
            else {
                printf("%c",str[i]);
            }
        }
        puts("");
    }

    return 0;
}
/*2017-08-06 19:43:04.244*/


#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define rep1(i,n) for(__typeof(n) i=1; i<=(n); i++)
#define rep2(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define inf 1061109567000LL
#define pi 3.14159265358979323846264338327950

#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

#define sz size()
#define eps 1e-9
#define vi vector<int>
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define mis map<int,string>
#define CLEAR(x) memset(x,0,sizeof(x));
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define mem(x,y) memset(x,y,sizeof(x));
#define N      10000000;
#define ll long long
#define case(n)   cout<<"Case "<<ca++<<": "<<n<<endl;
#define case1(n)  cout<<"Case "<<ca++<<"#: "<<n<<endl;
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
///usage.push_back(make_pair(x*a+y*b,i+1));
using namespace std;
int main()
{
    string s;
    while(cin>>s)
    {
    cout<<s[0];
    int i,ans=0;
    for(i=1;i<s.sz;i++)
    {
        if(ans==0 and s[i]=='a' and s[i+1]=='t' and i<s.sz-1)
        {
            cout<<"@";
            ans=1;
            i++;
           continue;
        }
        if(s[i]=='d' and s[i+1]=='o' and s[i+2]=='t' and i<s.sz-3)
        {
            cout<<".";
            i=i+2;
            continue;
        }
        cout<<s[i];
    }
    cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define LL "%I64d"
#define pb push_back
#define pp pop_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pss pair<string, string>
#define psi pair<string, int>
#define psll pair<string, ll>
#define vi vector<int>
#define vs vector<string>
#define vl vector<ll>
#define vc vector<char>
#define vv <vector<vector> >
#define mp make_pair
#define str(a, b) substr((a), (b))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define endl "\n"
#define sz size()
#define rr return
#define r0 return 0
#define mi map<int>
#define ms map<string>
#define ml map<ll>
#define all_sum(a,b) accumulate((a),(b),0)
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
using namespace std;
void adskiy_razgon(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int mxN=  1e+9+7;
const ll INF = 1e+18+7;
ll nod(ll a, ll b) {
    if(b > a) {
		swap(a, b);
	}
    while(b > 0) {
	    a %= b;
		swap(a, b);
    }
	return a;
}
ll nok(ll a,ll b) {
    return a * b / nod(a, b);
}
void sp(ll a,double b) {
    cout << fixed << setprecision(a) << b;
}
ll binpow (ll a, ll n) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 1) {
		return binpow (a, n - 1) * a;
	}
	else {
	    ll b = binpow (a, n / 2);
		return b * b;
	}
}

void solve() {
	string s;
	cin >> s;
	bool ok = 0;
	for(int i = 0; i < s.sz; ++i) {
		if(s[i] == 'a' && s[i + 1] == 't' && !ok && i != 0 && (i + 1) != s.sz - 1) {
			ok = 1;
			cout << '@';
			i++;
		}
		else {
			if(s[i] == 'd' && s[i + 1] == 'o' && s[i + 2] == 't' && i != 0 && (i + 2) != s.sz - 1) {
				cout << '.';
				i += 2;
			}
			else {
				cout << s[i];
			}
		}
	}
}
int main(){
	adskiy_razgon();
	ll t = 1;
//	cin >> t;
	for(int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve();
	}
	r0;
}


#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

int main()
{
    int f = 0;
    string str,str2;
    vector <string> ret;

    cin >> str;

    str2 += str[0];

    ret.push_back(str2);

    for (int i = 1 ; i < str.size()-1 ; i ++)
    {
        string x;
        string y;
        if (i + 2 < str.size()-1)
        {
            x += str[i];
            x += str[i+1];
            x += str[i+2];
        }
        if (i + 1 < str.size()-1)
        {
            y += str[i];
            y += str[i+1];
        }

        if (x == "dot")
        {
            str2 +='.';
            for (int j = 0 ; j < ret.size() ; j ++) ret[j] += '.';
            i += 2;
        }
        else if (y == "at")
        {
            f ++;
            for (int j = 0 ; j < f-1 ; j ++) ret[j] += "at";
            for (int j = f-1 ; j < ret.size() ; j ++) ret[j] += '@';
            str2 += str[i];
            str2 += str[i+1];
            ret.push_back(str2);
            i += 1;
        }
        else
        {
            str2 += str[i];
            for (int j = 0 ; j < ret.size() ; j ++) ret[j] += str[i];
        }
    }
    for (int j = 0 ; j < ret.size() ; j ++) ret[j] += str[str.size()-1];

    sort(ret.begin(), ret.end());

    cout << ret[0];
    //scanf("\n");
    return 0;
}
//aatabcdotcom


#include <iostream>
#include <string>

using namespace std;

int main() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	string s;
	cin >> s;
	int atpos = -1;
	for (int i = 1; i < s.length() - 1; ++i)
		if (s[i] == 'a' && s[i + 1] == 't' && i + 1 != s.length() - 1) {
			atpos = i;
			break;
		}
	cout << s[0];
	for (int i = 1; i < s.length(); ++i) {
		if (i + 2 < s.length() && s[i] == 'd' && s[i + 1] == 'o' && s[i + 2] == 't' && i+2 != s.length()-1) {
			cout << '.';
			i += 2;
			continue;
		}
		if (i == atpos) {
			cout << '@';
			++i;
			continue;
		}
		cout << s[i];
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
char a[101];
int len;
string s;
bool flag;
int main()
{
    scanf("%s",&a);
    len=strlen(a);
    for(int i=0;i<len;i++)
        if(a[i]=='@') flag=true;
    for(int i=0;i<len;i++)
    {
    	if(a[i]=='d'&&a[i+1]=='o'&&a[i+2]=='t'&&i!=0&&i!=len-3)
    	   s+='.',a[i]=' ',a[i+1]=' ',a[i+2]=' ';
    	if(a[i]=='a'&&a[i+1]=='t'&&i!=0&&i!=len-2&&flag==false)
		   s+='@',a[i]=' ',a[i+1]=' ',flag=true;
		else if(a[i]!=' ') s+=a[i];
	}
	cout<<s;
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#include <vector>
#include <math.h>

#define vi(v1) vector <ll> v1;
#define vc(v1) vector <char> v1;
#define vii(v1)  vector<pair<ll , ll >> v1;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
#define piarr(arr,i,n,str) for(ll j=i;j<n;j++){cout<<arr[j]<<" ";} cout<<"\n";

int main()
{
    string str;
    ll l,z=0;
    cin>>str;
    l=str.length();
    rep(i,0,l)
    {
        if(str.substr(i,2)=="at"&&i==0)
        {
            cout<<"at";
            i=i+1;
        }
        else if(str.substr(i,3)=="dot"&&i==0)
        {
            cout<<"dot";
            i=i+2;
        }
        else if(str.substr(i,2)=="at"&&i==l-2)
        {
            cout<<"at";

            break;
        }
        else if(str.substr(i,3)=="dot"&&i==l-3)
        {
            cout<<"dot";
            break;
        }
        else if(str.substr(i,2)=="at"&&z==0)
        {
            cout<<"@";
            z=1;
            i=i+1;
        }
        else if(str.substr(i,3)=="dot")
        {
            cout<<".";
            i=i+2;
        }
        else
        {
            cout<<str[i];
        }

    }
}


#include<iostream>
using namespace std;

string s;
char ans[100];
int p;
bool good;

int main()
{
	int i;
	cin>>s;
	for(i=0; i<s.length(); i++)
	{
		if(s[i]=='t' && i!=s.length()-1)
		{
			if(p>=2 && ans[p-1]=='a' && !good)
			{
				p-=1;
				ans[p++]='@';
				good=1;
			}
			else if(p>=3 && ans[p-2]=='d' && ans[p-1]=='o' )
			{
				p-=2;
				ans[p++]='.';
			}
			else ans[p++]=s[i];
		}
		else ans[p++]=s[i];
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

string str,ans;

int main(void){

   int taken=0,i;
   cin>>str;

   for(i=0;i<str.size();i++){

     if(str[i]!='a'&&str[i]!='d'){
        ans.push_back(str[i]);
        continue;
     }

    if(str[i ]=='a'){
       if(i==str.size()-1||(str[i+1]!='t')||ans.size()==0||taken){
         ans.push_back(str[i]);
         continue;
       }

       taken=1;
       ans.push_back('@');
       i++;
       continue;
    }

    //adot
    //0123
    if(str[i]=='d'){

       if(i>=str.size()-3||!(str[i+1]=='o'&&str[i+2]=='t')||ans.size()==0){
          ans.push_back(str[i]);
          continue;
       }

       ans.push_back('.');
       i+=2;
       continue;

    }

   }

   cout<<ans;

   return 0;

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int i,n,syc=0,t=0,k=0;
	string s;
	cin>>s;
	n=s.length();
	cout<<s[0];
	for(i=1;i<n-1;i++)
	{

		t=0;
		k=0;
		if(i<n-2)
		if(s[i]=='a' && s[i+1]=='t' && !syc)
		{
			cout<<'@';
			syc++;
			i++;
			continue;
		}
		if(i<n-3)
		if(s[i]=='d' && s[i+1]=='o' && s[i+2]=='t')
		{
			cout<<'.';
			i+=2;
			continue;
		}
		cout<<s[i];
	}
	cout<<s[n-1];
	return 0;

}


#include<bits/stdc++.h>

using namespace std;

void print(int n){

    if(n<5) cout<<"O-|";
    else cout<<"-O|";

    if(n % 5 == 0) cout<<"-OOOO"<<endl;
    else if(n % 5 == 1) cout<<"O-OOO"<<endl;
    else if(n % 5 == 2) cout<<"OO-OO"<<endl;
    else if(n % 5 == 3) cout<<"OOO-O"<<endl;
    else if(n % 5 == 4) cout<<"OOOO-"<<endl;
}
int main()
{
    vector<int>v;
    int n;
    cin>>n;

    if(n == 0) print(n);
    while (n){v.push_back(n%10);n/=10;}

    for(int i = 0; i < v.size(); i++){
        print(v[i]);
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,y,i;
	cin>>n;
	if(n==2)
	cout<<"2";
	else
	cout<<"1";
		return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mp                make_pair
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define hell              1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define chrng(n,a,b)      (((n)>=(a))&&((n)<=(b)))
#define clamp(n,a,b)      (((n)<(a))?(a):((((n)>(b))?(b):(n)))
int solve()
{
    ll a,cnt=0,g;char k;
    cin>>a>>k;

    g=a/4;
    if(a%4)  a=a%4;
	else   	 g--,a=4;
    cnt=g*16;
    if(a>2)a=a-2;
    cnt+=a/2*7;a=a%2;
         if(k=='f')cnt+=1;
    else if(k=='e')cnt+=2;
    else if(k=='d')cnt+=3;
    else if(k=='a')cnt+=4;
    else if(k=='b')cnt+=5;
    else if(k=='c')cnt+=6;
    cout<<cnt;

}
signed main(){
	ios_base::sync_with_stdio(false);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif

	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
	int t;
	string s;
	cin>>t;
	cin>>s;
	int stone = 0;
	for(int i = 0; i < t; i++){
		if(s[i] == '+'){
			stone++;
		}
		else{
			stone--;
		}
		if(stone < 0){
		stone = 0;
		}
	}

	cout<<stone;
}


#include <bits/stdc++.h>

using namespace std;
vector<int> a;
map<int, int> ans;
void reco(string s)
{
    int value = atoi(s.c_str());
    a.push_back(value);
}
void rec(string s)
{
    if(s.size() > 9){
        return ;
    }
    reco(s);
    rec(s+"4");
    rec(s+"7");
}

int main()
{
    string s ="";
    rec(s);
    sort(a.begin(), a.end());
    for(int i = 0; i < (int)a.size(); i++){
        ans[a[i]] = i;
    }
    int n;
    cin >> n;
    cout << ans[n];
}


#include<bits/stdc++.h>
using namespace std;
bool check(long long x){
	for(int i=2;i<=sqrt(x)+1;i++)if(x%i==0)return false;
	return true;
}
int main(){
	int T;
	long long a,b;
	cin>>T;
	while(T--){
		cin>>a>>b;
		if(a-b==1&&check(a+b))
			cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int n,i,x,ans;
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>x;
		if(x>0){
			ans+=x;
		}else{
			ans-=x;
		}
	}
	cout<<ans;
}


#include <iostream>
#include <cmath>
using namespace std;

int main() {
	int x, y, z, t1, t2, t3;
	int s, e;
	while(cin >> x >> y >> z >> t1 >> t2 >> t3) {
		s = abs(x - y) * t1;
		e = (abs(x - z) + abs(x - y)) * t2 + 3 * t3;
		if(s >= e)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}


//basic
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <climits>
#include <algorithm>
#include <cmath>
#include <array>
#include <cstdint>
#include <iterator>
//STL
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
//define
#define int int32_t
#define ll int64_t
#define dou double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define init(a,b) fill(begin(a),end(a),b)
#define sot(a,b) sort(a+1,a+1+b)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define rep0(i,a,b) for(int i=a;i<b;i++)
#define repa(i,a) for(auto &i:a)
#define eps 1e-8
//namespace
using namespace std;
//header end

int n,a[4],b[4];

int main()
{
    scanf("%d",&n);
    rep1(i,1,3) scanf("%d%d",&a[i],&b[i]);
    int x=min(n-a[2]-a[3],b[1]);
    int y=min(n-x-a[3],b[2]);
    int z=n-x-y;
    printf("%d %d %d\n",x,y,z);
    return 0;
}


#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const double eps=1e-8;
int main(){
	double a,b,c,d,ans;scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
	if ((b-a)==(c-b) && (c-b)==(d-c)) ans=d+(d-c);
	else
	if (b/a==c/b && c/b==d/c) ans=d*(d/c);
	else
		ans=42;
	if (ans-floor(ans)>eps && ceil(ans)-ans>eps) ans=42;
	printf("%d\n", (int)ans);
	return 0;
}


/************************************************
┆  ┏┓　　　┏┓ ┆
┆┏┛┻━━━┛┻┓ ┆
┆┃　　　　　　　┃ ┆
┆┃　　　━　　　┃ ┆
┆┃　┳┛　┗┳　┃ ┆
┆┃　　　　　　　┃ ┆
┆┃　　　┻　　　┃ ┆
┆┗━┓　  　┏━┛ ┆
┆　　┃　  　┃　　┆
┆　　┃　  　┗━━━┓ ┆
┆　　┃　 AC代马 　　┣┓┆
┆　　┃　        　　┏┛┆
┆　　┗┓┓┏━┳┓┏┛ ┆
┆　　　┃┫┫　┃┫┫ ┆
┆　　　┗┻┛　┗┻┛ ┆
************************************************ */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<string>
#define ll long long
using namespace std;

int Abs(int i)
{
    if(i<0) i=-i;
    return i;
}

int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        int l=0,r=0,mid=0;
        for(int i=1;i<=6;i++)
        {
            if(Abs(n-i)==Abs(m-i))
            {
                mid++;
            }
            else if(Abs(n-i)<Abs(m-i))
            {
                l++;
            }
            else
            {
                r++;
            }
        }
        printf("%d %d %d\n",l,mid,r);
    }
}


#include <iostream>

using namespace std;

long long int count(long long int x){
	long long int ans = 0;
	while (x != 0){
		ans += (x % 10);
		x /= 10;
	}
	return ans;
}

long long int solve(long long int x){
	long long int ans = x;
	long long int i = 10;
	while (x > 0){
		x = x - x % i - 1;
		if (count(x) > count(ans))
			ans = x;
		i *= 10;
	}
	return ans;
}

int main()
{
	long long int x;
	cin >> x;
	cout << solve(x);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

long long a, b;

long long func(int a) {
    if (a == 0 || a == 1) return 1;
    return a * func(a - 1);
}

int main() {
    scanf("%lld%lld", &a, &b);
    a = min(a, b);
    printf("%lld", func(a));
    return 0;
}


#include <iostream>
#include<math.h>
using namespace std;
int main(int argc, char** argv) {
    int n,a,r;
	cin>>n;
	int tabA[5]={0},tabB[5]={0};
	for(int i=0; i<n;i++)
	{ cin>>a;
	  tabA[a-1]+=1;
		}
    for(int i=0; i<n;i++)
	{ cin>>a;
	  tabB[a-1]+=1;
		}

	int c=0,k=0,t=0;
	for (int i=0; i<5;i++)
	{
	    if(tabA[i]!=tabB[i])
	    { r=abs(tabA[i]-tabB[i]);
	    if((r%2)==0)
	       { c+=(r/2); t++;
		   }
		}
		else { k++;
		}}
		if(((c%2)==0)&&(c!=0)&&(t>=2)) cout<<(c/2);
		else if(k==5) cout<<0;
		else cout<<-1;

	return 0;}


//#pragma comment(linker,"/STACK:100000000000,100000000000")

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <list>
#include <sstream>
#include <ctime>
#include <climits>
#include <bitset>
#include <list>
#include <cassert>
#include <complex>

using namespace std;

/* Constants begin */
const long long inf = 2e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-12;
const double PI = 2*acos(0.0);
const double E = 2.71828;
/* Constants end */

/* Defines begin */
#define pb push_back
#define mp make_pair
#define ll long long
#define double long double
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define forn(i,n) for (int (i)=0; (i)<(n); ++(i))
#define random S(rand()<<16|rand())
#define sqr(x) (x)*(x)
#define base complex<double>
/* Defines end */

double f[2][1005];

int n, m;

vector<double> a, b;

double C(int n, int m, bool ok = false){
  if(ok) swap(a, b);
  if(m == n){
    a.pb(1);
    b.pb(1);
  } else
  if(!m){
    a.pb(1);
    b.pb(1);
  } else {
    for(int i = 1; i <= m; ++i){
      b.pb(i);
    }
    for(int i = n - m + 1; i <= n; ++i){
      a.pb(i);
    }
  }
  if(ok) swap(a, b);
}

int main(void){
  #ifdef nobik
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
  #endif
  scanf("%d %d", &n, &m);
  double res = 0;
  f[0][0] = 1.0;
  for(int i = 1; i <= n * m; ++i){
    for(int j = 0; j <= m; ++j){
      //f[1][j + 1] += f[0][j] * (m - j) / (m * n - i + 1);
      //f[1][j] += f[0][j] * 6;
    }
  }
  if(m == 1){
    cout << setprecision(12) << fixed << 1.0 / n << endl;
    exit(0);
  }
  for(int i = 1; i <= min(n, m); ++i){
    double cur = 1.0 / (n + .0) * i * i;
    a.clear();
    b.clear();
    C(m, i);
    C(n * m - m, n - i);
    C(n * m, n, true);
    int it = 0;
    forn(i, a.size()){
      cur *= a[i];
      while(cur > 10 && it < b.size()) cur /= b[it++];
    }
    while(it < b.size()) cur /= b[it++];
    res += cur;
  }
  cout << setprecision(12) << fixed << res << "\n";
  return 0;
}


#include <math.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int p = 1e9 + 7;
ll poww(ll a, ll b) {
    ll ans = 1, base = a;
    while (b != 0) {
        if (b & 1 != 0)
            ans = ans * base % p;
            base = base * base % p;
            b >>= 1;
    }
    return ans % p;
}
int main() {
#ifdef ONLINE_JUDGE
#else
    freopen("c:\\code\\in.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll x, k, ans;
    scanf("%lld%lld", &x, &k);
    if(x == 0){
        cout << 0 << endl;
        return 0;
    }
    x = x % p;
    ans = (poww(2, (k + 1) % (p - 1)) % p * x % p - poww(2, k % (p - 1)) % p + 1 + p) % p;
    printf("%lld\n", ans);
    return 0;
}


// Amar_El-Bay
#include<bits/stdc++.h>
using namespace std ;
#define El_Bay ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sz(s) s.size()
#define ll  long long
#define pb  push_back
int main()
{
    El_Bay
    int _;
    cin>>_;
    while(_--)
    {
        string s;
        cin >> s;
        int x = s[0]-'0';
        int ans = (x-1)*10;
        if(sz(s)==1) ans+=1;
        else if(sz(s)==2) ans+=3;
        else if(sz(s)==3) ans+=6;
        else ans+=10;
        cout << ans << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int l = s.length();
    int cnt = 0;
    for(int i=0;i<l;i++)
    {
        if(s[i]<90)
        {
            if((s[i]-48)%2)
                cnt++;
        }
       else
            {
                if(s[i]=='a' || s[i]=='e' ||  s[i]=='i' || s[i]=='o' || s[i]=='u')
                    cnt++;
            }

    }
    cout<<cnt;
    return 0;
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <iomanip>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <cstdlib>
#include <cstdio>
#include <functional>
#include <memory.h>
#include <cassert>
#include <complex>
#include <ctime>
#include <limits>

using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;

using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vld = vector<ld>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
using vvi = vector<vi>;
using vvl = vector<vl>;

using si = set<int>;
using sl = set<ll>;

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define rs resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define nl "\n"
#define in cin
#define out cout

#define trav(i, x) for (auto& i: x)
#define rep(i, a, b) for(auto (i) = (a); i < (b); ++i)
#define per(i, a, b) for(auto (i) = (a - 1); i >= (b); --i)

const int MOD = 998244353;
const int MX = 5005;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

ll lcm(ll a, ll b) { return (a / (__gcd(a, b)) * b); }
ll gcd(ll a, ll b) { return (__gcd(a, b)); }
ll pow(ll a, ll b) { ll res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res; }

#define ts to_string
str ts(char c) { return str(1,c); }
str ts(bool b) { return b ? "true" : "false"; }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
template<class A> str ts(complex<A> c) {
	stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) {
	str res = "{"; for(int i = 0; i < sz(v); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) {
	str res = ""; for(int i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v) {
	bool fst = 1; str res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += ts(x);
	}
	res += "}"; return res;
}
template<class A, class B> str ts(pair<A,B> p) {
	return "("+ts(p.f)+", "+ts(p.s)+")"; }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << ts(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)

int n;

bool check(int x) {
	string s = to_string(x);
	int sum = 0;
	for(int i = 0; i < sz(s); i++) {
		sum += s[i] - '0';
	}
	if(sum == 10) {
		return true;
	} else {
		return false;
	}
}

int main() {
	cin >> n;
	int cnt = 0;
	for(int i = 19;; i += 9) {
		if(check(i) && cnt == n - 1) {
			cout << i << nl;
			break;
		} else if(check(i)) {
			cnt++;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int main ()
{
    string a , b;
    cin>>a>>b;
    for (int i=0; i<a.size(); i++)
    {
        if (tolower(a[i]) > tolower(b[i]))
        {
            cout<<1;
            return 0;
        }
        if (tolower(b[i]) > tolower(a[i]))
        {
            cout<<-1;
            return 0;
        }
        else
        {
            if (i == a.size()-1)
            cout<<0;

        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll q,ans=2,sum=0;
int main(){
    cin>>q;
    for(int i=2;i<=q;i++) sum+=ans,ans=ans*2;
    sum+=ans;
    cout<<sum<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long qpow(long long a, long long b)
{
	long long res = 1;
	while (b)
	{
		if (b & 1)
		{
			res = (res * a) % mod;
		}
		a = (a * a)%mod;
		b /= 2;
	}
	return res%mod;
}
int main()
{
	        int t;
			long long n;
			cin >> n;
			long long u = 2;
			long long ks = pow(2,n);
			long long kk = qpow(u*2, (ks - 2)) % mod;
			long long cf = (kk*6)%mod;
			cout << cf << endl;
}


#define _HAS_ITERATOR_DEBUGGING 0
#define _ITERATOR_DEBUG_LEVEL 0
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <list>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>

#define setzero(arr) memset(arr, 0, sizeof(arr))

int ___read_tmp;
#define fi(i, from, to) for(int i = (from); i < (to); i++)
#define fri(i, from, to) for(int i = (from); i >= (to); i--)
#define fa(it, col) for(auto (it) = (col).begin(); (it) != (col).end(); (it)++)
#define fra(it, col) for(auto (it) = (col).rbegin(); (it) != (col).rend(); (it)++)
#define getBit(vv, bit) ((vv & (lol)(1LL << (31 - bit))) == 0LL ? 0 : 1)
#define getBit64(vv, bit) ((vv & (lol)(1LL << (63 - bit))) == 0LL ? 0 : 1)
#define vecits(obj) obj.begin(), obj.end()
#define strip_string(str) (str)[strcspn((str), "\r\n")] = 0;
#define read_int() (scanf("%d ", &___read_tmp), ___read_tmp)
#define MOD 1000000007
#define PI 3.14159265
#define INF 10000000
//#define FILE_IO "peacefulsets"

typedef unsigned long long lol;
typedef  long long slol;
using namespace std;

bool used[35000];
unordered_map<int, int> mm;

int calc_sg(int vv)
{
	if (vv == 0)
		return 0;

	auto res = mm.find(vv);
	if (res != mm.end())
		return res->second;

	bool sg_vals[40];
	memset(sg_vals, 0, sizeof(sg_vals));
	fi(i, 1, 29)
	{
		if ((vv & (1 << i)) == 0)
			continue;

		int v2 = vv;
		for (int k = 1; k < 50; k ++)
		{
			int pos = (i + 1)*k - 1;
			if (pos >= 29)
				break;

			v2 &= ~(1 << pos);
		}

		sg_vals[calc_sg(v2)] = true;
	}

	int mex = 40;
	fi(i, 1, 40)
	{
		if (!sg_vals[i]) {
			mex = i;
			break;
		}
	}

	mm[vv] = mex;
	return mex;
}

int sg_sizes[30] =  {0, 1, 2, 1, 4, 3, 2, 1, 5, 6, 2, 1, 8, 7, 5, 9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12 };
bool skip[35000];

int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#elif defined(FILE_IO)
	freopen(FILE_IO ".in", "r", stdin);
	freopen(FILE_IO ".out", "w", stdout);
#endif

	/*calc_sg((1 << 29) - 1);
	fi(i, 1, 30)
	{
		sg_sizes[i] = mm[(1 << i) - 1];
	}
	*/

	int nn;
	scanf("%d", &nn);
	lol n = nn;

	lol max_v = 0;
	fi(i, 1, n+1)
	{
		if (i*i <= n)
			max_v = i;
		else
			break;
	}

	int res = 0;
	int taken = 0;
	fi(i, 2, n)
	{
		if (i*i > n)
			break;

		if (skip[i])
			continue;

		lol tmp = i, cnt = 0;
		while (tmp <= max_v)
		{
			skip[tmp] = true;
			cnt++;
			tmp *= i;
		}

		while (tmp <= n)
		{
			tmp *= i;
			cnt++; taken++;
		}

		res ^= sg_sizes[cnt];
	}

	int emp = n - max_v - taken;
	if (max_v > 0) emp++;
	res ^= emp % 2;

	if (res != 0)
	{
		printf("Vasya");
	}
	else {
		printf("Petya");
	}

	return 0;
}


#include <iostream>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>

#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define iter iterator

using namespace std;

int main()
{
    int def1, atk1, def2, atk2, def3, atk3, def4, atk4;
    cin >> def1 >> atk1 >> def2 >> atk2 >> def3 >> atk3 >> def4 >> atk4;
    if ((((atk1 > def3) && (def2 > atk4)) && ((atk1 > def4) && (def2 > atk3))) || (((def1 > atk3) && (atk2 > def4)) && ((def1 > atk4) && (atk2 > def3))))
        cout << "Team 1" << endl;
    else if ((((atk3 > def1) && (def4 > atk2)) || ((def3 > atk2) && (atk4 > def1))) && (((def3 > atk1) && (atk4 > def2)) || ((atk3 > def2) && (def4 > atk1))))
        cout << "Team 2" << endl;
    else
        cout << "Draw" << endl;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll; typedef pair<ll, pi> plp;
typedef tuple<int, int, int> ti; typedef tuple<ll, int, int> tli;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF * 2;

ll mul(ll a, ll b, ll mod) {
	a %= mod;
	ll res = 0, p = a;
	while(b) {
		if(b%2) res += p, res %= mod;
		p += p; p %= mod; b>>=1;
	}
	return res;
}
ll a_b(ll a, ll b, ll mod) {
	a %= mod;
	ll res = 1, p = a;
	while(b) {
		if(b%2) res = mul(res, p, mod);
		p = mul(p, p, mod); b>>=1;
	}
	return res;
}

const int MAX_P = 40;
//if n < 18446744073709551616 = 2^64
//it is enough to test a = 2  3  5  7  11  13  17  19  23  29  31  and 37
vector<int> Ps; bool notP[MAX_P], isFirst = true;
bool isPrime(ll n) { //Miller–Rabin_primality_test
	if(isFirst) {
		isFirst = false;
		notP[0] = notP[1] = true;
		for(int i=2; i<MAX_P; i++) if(notP[i] == false) {
			Ps.push_back(i);
			for(int j=i*2; j<MAX_P; j++) notP[j] = true;
		}
	}
	int s=0; ll m = n-1;
	while((m&1) == 0) m >>= 1, s++;
	for(int x : Ps) if(n == x) return true;
	for(int x : Ps) if(n % x == 0) return false;

	for(int x : Ps) {
		ll now = a_b(x, m, n);
		bool isCom = true;
		if(now == 1) continue;
		for(int i=0; i<s; i++) {
			if(now == n-1) { isCom = false; break; }
			now = mul(now, now, n);
		}
		if(isCom) return false;
	}
	return true;
}

ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}

ll getF(ll a, ll b) {
	if(b == 0) return 0;
	return 1 + getF(a, b - gcd(a, b));
}

vector<ll> Div;
ll myF(ll A, ll B) {
//	printf("%lld %lld\n", A, B);
	if(A == 1) return B;
	if(B == 0) return 0;
	if(isPrime(A)) {
		ll v = B % A; B -= v;
		v += B / A;
		return v;
	}
	if(B % A == 0) return B / A;

	ll g = gcd(A, B);
	ll cnt = 1, na = A/g;
	ll b = B/g - 1;

	if(isPrime(na)) {
		cnt += b % na;
		b -= b % na;
	}else{
		while(gcd(b, na) == 1 && b > 0) b--, cnt++;
	}
	ll ans = cnt + myF(na, b);
	return ans;
}
int main() {
//	for(int i=1; i<=7; i++, puts("")) for(int j=0; j<=30; j++) printf("%3lld", getF(i, j));

//	return 0;
	/*
	for(int i=1; i<=10; i++) for(int j=1; j<=10; j++) {
		printf("[%d %d]\n", i, j);
		if(myF(i, j) != getF(i, j)) {
			printf("%d %d [%lld %lld]\n", i, j, myF(i, j), getF(i, j));
			puts("FUCK");
			return 0;
		}
	}
	//*/
	ll a, b;
	cin >> a >> b;
	printf("%lld\n", myF(a, b));
	return 0;
}


#include<iostream>
#include<cstdio>
#define N 1005
using namespace std;
int n,m,ci,di,dp[N],ai,bi,obj[N],tot,vi[N],wi[N];
int main()
{
	scanf("%d%d%d%d",&n,&m,&ci,&di);
	for(int i=ci;i<=n;i++)
		dp[i]=dp[i-ci]+di;
	for(int i=1;i<=m;i++)
	{
		tot=0;
		scanf("%d%d%d%d",&ai,&bi,&ci,&di);
		int maxb=ai/bi;
		int base=1;
		while(base<=maxb)
		{
			obj[++tot]=base;
			wi[tot]=base*ci;
			vi[tot]=base*di;
			maxb-=base;
			base<<=1;
		}
		if(maxb)
		{
			obj[++tot]=maxb;
			wi[tot]=maxb*ci;
			vi[tot]=maxb*di;
		}
		for(int k=1;k<=tot;k++)
			for(int j=n;j>=wi[k];j--)
					dp[j]=max(dp[j],dp[j-wi[k]]+vi[k]);
	}
	printf("%d",dp[n]);
}


#include <bits/stdc++.h>
#define FIT(a,b) for(vector<int >::iterator a=b.begin();a!=b.end();a++)
#define FOR(a,b,c) for(int a=(b);a<=(c);++a)
#define ROF(a,b,c) for(int a=(b);a>=(c);--a)
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define TATA NULL
using namespace std;
const int MOD = 1000000007;
const int buffer = 200004;
const int NMAX = 1004;
inline int Pow(const int x,const int n)
{
    if(n==0)
        return 1;
    if(n&1)
        return 1LL*x*Pow(x,n-1)%MOD;
    int a = Pow(x,n/2);
    return 1LL*a*a%MOD;
}

int dp[NMAX], fact[NMAX*NMAX], inv[NMAX*NMAX],n, m, k;
int dp1[NMAX],sum[NMAX][2];
inline int Comb(const int n,const int k)
{
    if(k > n)
        return 0;
    int ret = 1LL*fact[n]*inv[n-k]%MOD;
    return 1LL*ret*inv[k]%MOD;
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif // ONLINE_JUDGE
    cin >> n >> m >> k;
    fact[0] = inv[0] = 1;
    FOR(i,1,max(n,k))
    {
        fact[i] = 1LL*fact[i-1]*i%MOD;
        inv[i] = Pow(fact[i],MOD-2);
    }
    FOR(i,1,n)
    {
        dp[i] = Pow(i,n);
        FOR(j,1,i-1){
            dp[i] -= 1LL*dp[j]*Comb(i,j)%MOD;
            if(dp[i] < 0)
                dp[i] += MOD;
        }
    }
    int ans = 0, x, y, z;
    if(m==1)
    {
        FOR(distincte,1,min(n,k))
        {
            ans += 1LL*dp[distincte]*Comb(k,distincte)%MOD;
            ans %= MOD;
        }
        cout<<ans<<"\n";
        return 0;
    }
    if(m==2)
    {
        FOR(distincte,1,min(n,k))
        {
            x = 1LL*dp[distincte]*Comb(k,distincte)%MOD;
            x = 1LL*x*x%MOD;
            ans = (ans+x)%MOD;
        }
        cout<<ans<<"\n";
        return 0;
    }
    FOR(i,1,n)
        dp1[i] = (Pow(sum[i][1],m-2)-Pow(sum[i][0],m-2)+MOD)%MOD;
    FOR(i,1,n){
        FOR(j,1,i-1)
            sum[i][0] = (sum[i][0] + 1LL*Comb(i,j)*dp[j]%MOD)%MOD;
        sum[i][1] = (sum[i][0]+dp[i])%MOD;
    }
    FOR(distincte,1,min(n,k))
    {
        FOR(intersect,1,distincte)
        {
            x = 1LL*dp[distincte]*Comb(k,distincte)%MOD;
            z = 1LL*Pow(intersect,n*(m-2))*Comb(distincte,intersect)%MOD;
            y = 1LL*dp[distincte]*Comb(k-distincte,distincte-intersect)%MOD;
            x = 1LL*x*y%MOD;
            x = 1LL*x*z%MOD;
            ans = (ans+x)%MOD;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


#include <cstdio>

using namespace std;

int main()
{
	int k, n, s, p;
	scanf("%d%d%d%d", &k, &n, &s, &p);
	int t;
	if (n / s == 0)
	{
		t = 1;
	}
	else
	{
		t = n / s + (n%s == 0 ? 0 : 1);
	}
	int ans;
	ans = t*k / p + (t*k%p == 0 ? 0 : 1);
	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main() {
    long long a,b;
    cin>>a>>b;
    long long kn=a/(b+1)/2;
    cout<<kn<<" "<<kn*(b)<<" "<<a-kn- kn*(b)<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2005,mod=998244353;
int n;
ll A,B,p,pw[N],pw2[N],f[N],g[N][N],h[N];
ll Pow(ll x,ll k){
	ll ret=1;
	while(k){
		if(k&1)ret=ret*x%mod;
		k>>=1;x=x*x%mod;
	}
	return ret;
}
ll C2(ll n){
	return n*(n-1)/2;
}
int main(){
	scanf("%d%d%d",&n,&A,&B);
	p=(ll)A*Pow(B,mod-2)%mod;
	pw[0]=pw2[0]=1;
	for(int i=1;i<=n;i++){
		pw[i]=pw[i-1]*p%mod;
		pw2[i]=pw2[i-1]*(1-p)%mod;
	}
	for(int i=0;i<=n;g[i++][0]=1)
		for(int j=1;j<=i;j++){
			g[i][j]=(g[i-1][j]*pw2[j]+g[i-1][j-1]*pw[i-j])%mod;
		}
	for(int i=1;i<=n;i++){
		h[i]=1;
		for(int j=1;j<i;j++)h[i]=(h[i]-h[j]*g[i][j])%mod;
	}
	for(int i=1;i<=n;i++){
		ll tot=0;
		for(int j=1;j<=i;j++)tot=(tot+g[i][j]*h[j]%mod*((C2(j)+j*(i-j)+f[i-j]+f[j])%mod))%mod;
		f[i]=tot*Pow(1-g[i][i]*h[i]%mod,mod-2)%mod;
	}
	cout<<(f[n]+mod)%mod<<"\n";
}


#include<cstdio>
#include<iostream>

using namespace std;

int n[15], a[15];
int cnt = 1;
char c;
int main()
{
	while(c < '0' || c > '9') c = getchar();
	while(c >= '0' && c <= '9')
	{
		n[cnt] = c - '0';
		c = getchar();
		cnt++;
	}
	int ans = 0;
	for(int i = cnt-1; i >= 1; i--)
	{
		if(i != 1) n[i] -= 9;
		if(n[i] < 0)
		{
			n[i-1]--;
			n[i] += 10;
		}
		ans += 9;
		ans += n[i];
		//cout <<n[i] << " " << ans << endl;
	}
	cout << ans - 9;
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma loop_opt(on)
#define debug(x) (cerr<<#x<<" = "<<x<<'\n')
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll N = 1<<18, MOD = 1000000007;
namespace dsu {
int pa[N],rk[N];
void init(int n) {iota(pa,pa+n,0),memset(rk,0,sizeof(int)*n);}
int anc(int x) {return x==pa[x] ? x : (pa[x]=anc(pa[x]));}
bool uni(int x,int y) {
    if((x=anc(x))==(y=anc(y))) return false;
    if(rk[x] < rk[y]) swap(x,y);
    return pa[y] = x, rk[x]!=rk[y]||++rk[x];
}
}
using namespace dsu;
ll mdp(ll e,ll p) {
    ll r = 1;
    while(p) (p&1)&&(r=r*e%MOD), e=e*e%MOD, p>>=1;
    return r;
}
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    ll n,m,k;
    cin >> n >> m >> k;
    init(n);
    for(int i = 0; i+k-1 < n; i++) {
        for(int j = 0; j < k; j++) {
            int a = i+j;
            int b = i+k-1-j;
            //debug(a), debug(b);
            uni(a,b);
        }
    }
    vector<int> v;
    for(int i = 0; i < n; i++) v.push_back(anc(i));
    sort(v.begin(), v.end()), v.erase(unique(v.begin(),v.end()), v.end());
    //for(int p:v) cout << p << ' '; cout << '\n';
    cout << mdp(m,v.size()) << '\n';
}


#include<bits/stdc++.h>
using namespace std;
unsigned long long n,m;
int main()
{
	scanf("%lld%lld",&n,&m);
	if(m==1) printf("%lld",n-1);
	else printf("%lld",n*(m-1));
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
char str[10];
int a[11];
int main()
{
    a[0]=2;
    a[1]=7;
    a[2]=2;
    a[3]=3;
    a[4]=3;
    a[5]=4;
    a[6]=2;
    a[7]=5;
    a[8]=1;
    a[9]=2;
    scanf("%s",str);
    cout<<a[(int)str[0]-48]*a[(int)str[1]-48]<<endl;
    return 0;
}


#include<iostream>
#include<cmath>
#include<map>
using namespace std;

int main()
{
	map<int,int>m;
	m[1]=4; m[2]=4; m[3]=4; m[4]=4; m[5]=4; m[6]=4; m[7]=4; m[8]=4; m[9]=4;
	m[10]=15; m[11]=4;
	int n;
	int k;
	int p=0;
	cin>>n;
	if(n<10) cout<<"0";
	else if(n-10>11) cout<<"0";
	else
	{
		k=abs(n-10);
		cout<<m[k];
	}
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include<math.h>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<set>
#include<ctime>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#define inf 2000000000
#define INF 1<<29
#define s(a) scanf("%d",&a)
#define me(a,b) memset(a,b,sizeof(a))
typedef long long ll;
using namespace std;
const int maxn=1e6+5;
const int mo=1e9+7;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
priority_queue<ll,vector<ll>,less<ll> >q;

int main()
{
	//freopen("diversity.in","r",stdin);
    //freopen("diversity.out","w",stdout);
	int n;

	while(~s(n)){
		for (int i=1;i<=10000;i++) {
		if (i*i>=n) {
			printf("%d\n",4*i);
			return 0;
		} else if (i*(i+1)>=n) {
			printf("%d\n",4*i+2);
			return 0;
		}
		}
	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int u=1,v=1,n,p=0,k;
    string s;
    cin>>s;
    n=s.length();
    for(int i=0;i<n-1;i++)
    v*=9;
    if(s[0]!='1')
    v*=(s[0]-'1');
    k=n-1;
    for(int i=0;i<k;i++)
    if(p==1)
    s[i]='9';
   else if(s[i]>s[i+1] ){
     s[i]--;
    p++;
    k++;
    }
    for(int i=0;i<n;i++)
    u*=s[i]-'0';
    cout<<max(u,v);
}


#include <bits/stdc++.h>
using namespace std;
vector<long long int> vaibhav1;
void nandan(int o,int limi)
{
	if(o==limi)
	{
		return;
	}
	int y=pow(2,o)-1;
	for(int i=0; i<=y; i++)
	{
		int A[o];
		int w=i;
		for(int j=0; j<o;j++)
		{
			A[j]=w%2;
			w=w/2;
		}
		long long int sum=0;
		for(long long int j=0; j<o;j++)
		{
			if(A[j]==0)
			{
				sum+=(pow(10,j))*4;
			}
			else{
				sum+=(pow(10,j))*7;
			}
		}
		vaibhav1.push_back(sum);
	}

	nandan(o+1,limi);
}
bool f(int index, long long int k,long long int n)
{
	long long int A[14];
	A[0]=0;
	A[1]=1;
	for(long long int i=2;i<=13;i++)
	{
		A[i]=A[i-1]*i;
	}

	set<long long int> vaibhav;
	set<long long int> :: iterator it ;
	for(int i=n-13; i<=n; i++)
	{
		vaibhav.insert(i);
	}
	int l=13;
	map<long long int, long long int> yoyo;
	int active=0;
	for(int i=n-13; i<=n; i++)
	{
		if(active==1)
		{
			it=vaibhav.end();
			it--;
			yoyo[i]=*(it);
			vaibhav.erase(it);
		}
		else if(k>=A[l]&&l!=0)
		{
		  int u=(k-1)/A[l];
		  it =vaibhav.begin();
		  if(k%A[l]==0)
		  {
		  	active=1;
		  }
		  while(u--)
		  {
		  	it++;
			  }
			yoyo[i]=*it;
			//cout<<*it<<" "<<i;
			vaibhav.erase(it);
			k=k%A[l];
		}
		else{
			yoyo[i]=*(vaibhav.begin());
			vaibhav.erase(vaibhav.begin());
		}
		//cout<<yoyo[i]<<" "<<i<<"\n";
		l--;
	}
	int flag=1;
	if(yoyo.find(index)!=yoyo.end())
	{
		long long int po=yoyo[index];
		while(po)
		{
			if(po%10==4||po%10==7)
			{

			}
			else{
				flag=0;
			}
			po/=10;
		}
	}

		return flag;
}
void solve()
{
	long long int n,k,ans=0,sum=1;
	cin>>n>>k;

	if(n<=14)
	{
		for(long long int i=1;i<=n; i++)
		{
			sum=sum*i;
		}
		if(sum<k)
		{
			cout<<"-1\n";
			return;
		}
	}
	//cout<<"vaibhav";
	nandan(1,10);
	sort(vaibhav1.begin(),vaibhav1.end());
	for(int i=0; i<vaibhav1.size(); i++)
	{
		//cout<<"vaibhav";
		if(vaibhav1[i]>n)
		{
			break;
		}
		if(f(vaibhav1[i],k,n))
		{
			ans++;
		}
	}
	cout<<ans<<"\n";
}
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
   int t;
  // cin>>t;
  t=1;

   while(t--)
   {
   	      solve();
   }
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c;
    x=(a*b)+(b*c)+(c*a)-a-b-c+1;
    cout << x << endl;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define N 510
#define mod 998244353
using namespace std;
int t, n, x;
ll dp[N][N], ans, fact[N], pwd[N][N], c[N][N];
ll power(int x, int n){
	if(x < N && n < N && pwd[x][n] != -1) {
		return pwd[x][n];
	}
	if(n == 0)
		return 1ll;
	ll y = power(x, n/2);
	y = (y*y) % mod;
	if(n % 2)
		return (1ll * x * y) %mod;
	return y;
}
ll ncr(int n, int r){
	if(r > n)
		return 0ll;
	return c[n][r];
}
int main() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(10);
    fact[0] = 1ll;
    for(int i=1; i < N; i++) {
    	fact[i] = (1ll * i * fact[i-1]) % mod;
    }
    for(int i = 0; i < N; i++) {
    	for(int j = 0; j < N; j++) {
    		pwd[i][j] = -1;
    		pwd[i][j] = power(i, j);
    	}
    }

	c[0][0] = 1;
	for (int i = 1; i < N; ++i) {
   		c[i][0] = c[i][i] = 1;
    	for (int j = 1; j < i; ++j) {
        	c[i][j] = (c[i - 1][j - 1] + c[i - 1][j])%mod;
    	}
	}
    cin >> n >> x;
    for(int i = 2; i <= n; i++) {
    	for(int k=1; k <= x; k++) {
    		if(k < i) {
    			dp[i][k] = power(k, i) - power(k-1, i);
    			if(dp[i][k] < 0ll)
    				dp[i][k] += mod;
    		} else {
    			for(int j = i; j > 1; j--) {
    				dp[i][k] = (dp[i][k] + ( (ncr(i, i-j) * power(i-1, (i-j)) ) % mod * dp[j][k - (i-1)]) % mod) % mod;
    			}
    		}
    		if(i == n) {
    			ans = (ans + dp[i][k]) % mod;
    		}
    	}
    }
    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
long long n,p;
long long sum;
long long tmp;
int main(){
    cin>>n>>p;
    sum=0;
    for(int i=1;i<=n;i++){
        tmp=i;
        int k=i;
        while(k){
            tmp=tmp*10+k%10;
            k/=10;
        }
        sum+=tmp;
        sum%=p;
    }
    cout<<sum;
}


// a
#include <iostream>
using namespace std;
int main(){
	string s,ans;
	int n;
	cin>>n>>s;
	s=s+"##";
	for(int i=0;i<n;i++){
		if(s[i]=='o'){
			if(s[i+1]=='g' && s[i+2]=='o'){
				ans=ans+"***";
			}else ans+=s[i];
			while(s[i+1]=='g' && s[i+2]=='o' && i<n){
				i+=2;
			}

		}else{
			ans+=s[i];
		}
	}
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
long long m,a,b,sol,lst,ma,t;
long long nr,f;
long long gaus(long long n)
{
    n*=n+1;
    n/=2;
    return n;
}
long long solve(long long n,long long m)
{
    long long ret;
    ret=n*m;
    ret-=gaus(n-1)*a;
    return ret;
}
int main()
{
    cin>>m>>a>>b;
    sol=solve((m/a)+1,m+1);
    lst=b;
    while(b%a)
    {
        while(t<lst)
        {
            nr++;
            t+=a;
        }
        ma=max(ma,t);
        if(t>m)
            break;
        //cout<<b<<' '<<t<<'\n';
        t-=lst;
        //cout<<(1+(ma-t)/a)<<'\n';
        //cout<<t<<'\n';
        sol+=(((ma-t)/a)+1)*(m-ma+1);
        f=t;
        f+=(((ma-t)/a)+1)*a;
        b+=lst;
        if(f>m)
            continue;
        sol+=solve(1+(m-f)/a,m-f+1);
    }
    cout<<sol;
}


#include<bits/stdc++.h>

using namespace std;
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define pi 3.1415926535897932384626433832795028841971
#define n 8
int a[n][n];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
bool check(){
	int i,j,k;
	REP(i,n)REP(j,n)if(a[i][j]==1||a[i][j]==2){
		REP(k,4){
			int x=i+dx[k];
			int y=j+dy[k];
			for(;0<=x&&x<n&&0<=y&&y<n&&a[x][y]==0;x+=dx[k],y+=dy[k]);
			if(0<=x&&x<n&&0<=y&&y<n&&a[x][y]==4)return true;
		}
	}
	return false;
}
int main(){
	char r1[5],r2[5],kw[5],kb[5];
	while(scanf("%s %s %s %s",r1,r2,kw,kb)>0){
		int x1,y1,x2,y2,x3,y3,x4,y4;
		x1=r1[0]-'a',y1=r1[1]-'1';
		x2=r2[0]-'a',y2=r2[1]-'1';
		x3=kw[0]-'a',y3=kw[1]-'1';
		x4=kb[0]-'a',y4=kb[1]-'1';
		bool mate=true;
		int x,y;
		for(x=x4-1;x<=x4+1;x++)for(y=y4-1;y<=y4+1;y++){
			if(0<=x&&x<n&&0<=y&&y<n)
				if(abs(x-x3)>1||abs(y-y3)>1){
					REP(i,8)REP(j,8)a[i][j]=0;
					a[x1][y1]=1;
					a[x2][y2]=2;
					a[x3][y3]=3;
					a[x][y]=4;
					if(!check())mate=false;
				}
		}
		puts(mate?"CHECKMATE":"OTHER");
	}
	return 0;
}
/*
a6 b4 c8 a8
a6 c4 b6 b8
a2 b1 a3 a1
*/


#include <iostream>
#include <algorithm>

using ll = long long;

ll n, v, rest, l, r, mid;

int ok(ll x)
{
	v = 0;
	rest = n;
	while (rest > 0)
	{
		v += std::min(x, rest);
		rest -= std::min(x, rest);
		rest -= rest / 10;
	}
	return (v * 2 >= n);
}

int main()
{
	std::cin >> n;
	l = 1, r = n;
	while (l < r)
	{
		mid = (l + r) >> 1;
		if (ok(mid))
			r = mid;
		else
			l = mid + 1;
	}
	std::cout << l << std::endl;
}


#include <iostream>
#include <string>
#include <cmath>
#include<iomanip>
using namespace std;
int main()

{
int n,m,min;
cin>>n>>m;

if(m<n)
min=m;
else
min=n;
if(min%2==0)
cout<<"Malvika";
else
cout<<"Akshat";

return 0;
}


#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <algorithm>
#include <map>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int ms = 5001000;
const int lim_n = 3e5;
const int lim_p = 3e2;

std::vector<int> primes;
int id[ms];
int memo[lim_n][lim_p];
void pre() {
	std::vector<bool> isPrime(ms, true);
	for(int i = 2; i < ms; i++) {
		id[i] = (int) primes.size();
		if(!isPrime[i]) continue;
		id[i]++;
		primes.push_back(i);
		for(int j = i+i; j < ms; j += i) {
			isPrime[j] = false;
		}
	}
	for(int i = 1; i < lim_n; i++) {
		memo[i][0] = i;
		for(int j = 1; j < lim_p; j++) {
			memo[i][j] = memo[i][j-1] - memo[i/primes[j-1]][j-1];
		}
	}
}

int cbc(long long n) {
	int ans = std::max(0, (int) pow((double) n, 1.0 / 3) - 2);
	while((long long) ans * ans * ans < n) ans++;
	return ans;
}

long long dp(long long n, int i) {
	if(n == 0) return 0;
	if(i == 0) return n;
	if((long long) primes[i-1] * primes[i-1] > n && n < ms) {
		return id[n] - (i-1);
	} else if(n < lim_n && i < lim_p) {
		return memo[n][i];
	} else {
		return dp(n, i-1) - dp(n / primes[i-1], i-1);
	}
}

long long primeFunction(long long n) {
	if(n < ms) {
		return id[(int)n];
	}
	int i = id[cbc(n)];
	long long ans = dp(n, i) + i - 1;
	while((long long) primes[i] * primes[i] <= n) {
		ans -= primeFunction(n / primes[i]) - i;
		i++;
	}
	return ans;
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	pre();
	long long n;
	std::cin >> n;
	long long ans = 0;
	for(int i = 0; i < (int) primes.size(); i++) {
		if((long long) primes[i] * primes[i] > n) break;
		if((long long) primes[i] * primes[i] * primes[i] <= n) ans++;
		ans += primeFunction(n / primes[i]) - (i+1);
	}
	std::cout << ans << '\n';
}


#include <iostream>
#include<cmath>
using namespace std;

int main() {
	int x1, x2, y1, y2;
	long long m,n;
	cin>>x1>>y1>>x2>>y2;
	m=x2-x1;
	n=y2-y1;
	if(m % 2 == 0){
		cout<<m*(m/2+1)+1+(m+1)*(n/2-m/2)<<endl;
	}
	if(m % 2 != 0){
		cout<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define an "\n"

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	if(s.size()==2) {
		if(stoi(s)>=10 && stoi(s)<=19) {
			if(s[1]=='0') {
				cout << "ten";
			}else if(s[1]=='1') {
				cout << "eleven";
			}else if(s[1]=='2') {
				cout << "twelve";
			}else if(s[1]=='3') {
				cout << "thirteen";
			}else if(s[1]=='4') {
				cout << "fourteen";
			}else if(s[1]=='5') {
				cout << "fifteen";
			}else if(s[1]=='6') {
				cout << "sixteen";
			}else if(s[1]=='7') {
				cout << "seventeen";
			}else if(s[1]=='8') {
				cout << "eighteen";
			}else if(s[1]=='9') {
				cout << "nineteen";
			}
			return 0;
		}

		if(s[1]=='0') {
			if(s[0]=='2') {
				cout << "twenty";
			}else if(s[0]=='3') {
				cout << "thirty";
			}else if(s[0]=='4') {
				cout << "forty";
			}else if(s[0]=='5') {
				cout << "fifty";
			}else if(s[0]=='6') {
				cout << "sixty";
			}else if(s[0]=='7') {
				cout << "seventy";
			}else if(s[0]=='8') {
				cout << "eighty";
			}else if(s[0]=='9') {
				cout << "ninety";
			}
			return 0;
		}
		if(s[1]!='0') {
			if(s[0]=='2') {
				cout << "twenty";
			}else if(s[0]=='3') {
				cout << "thirty";
			}else if(s[0]=='4') {
				cout << "forty";
			}else if(s[0]=='5') {
				cout << "fifty";
			}else if(s[0]=='6') {
				cout << "sixty";
			}else if(s[0]=='7') {
				cout << "seventy";
			}else if(s[0]=='8') {
				cout << "eighty";
			}else if(s[0]=='9') {
				cout << "ninety";
			}
			cout << "-";
			if(s[1]=='1') {
				cout << "one";
			}else if(s[1]=='2') {
				cout << "two";
			}else if(s[1]=='3') {
				cout << "three";
			}else if(s[1]=='4') {
				cout << "four";
			}else if(s[1]=='5') {
				cout << "five";
			}else if(s[1]=='6') {
				cout << "six";
			}else if(s[1]=='7') {
				cout << "seven";
			}else if(s[1]=='8') {
				cout << "eight";
			}else if(s[1]=='9') {
				cout << "nine";
			}
			return 0;
		}
	}else {
		if(s[0]=='0') {
			cout << "zero";
			return 0;
		}
		if(s[0]=='1') {
			cout << "one";
		}else if(s[0]=='2') {
			cout << "two";
		}else if(s[0]=='3') {
			cout << "three";
		}else if(s[0]=='4') {
			cout << "four";
		}else if(s[0]=='5') {
			cout << "five";
		}else if(s[0]=='6') {
			cout << "six";
		}else if(s[0]=='7') {
			cout << "seven";
		}else if(s[0]=='8') {
			cout << "eight";
		}else if(s[0]=='9') {
				cout << "nine";
		}
	}
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,a,x,b,y,flag=0,i;
    cin>>n>>a>>x>>b>>y;

    for( i=1;i<=n;i++)
    {

        if(a==b)
        {
            cout<<"YES"<<endl;
            return 0;
        }
if(a==x||b==y)
{
    flag++;
    break;
}
        if(a==n)
            a=0;
         if(b==1)
            b=n+1;

        a++;
           b--;
    }
    if(flag||i==n+1)
        cout<<"NO"<<endl;
}


// luogu-judger-enable-o2
#include<iostream>

using namespace std;

int n, a, b ;

int main(){

    cin >> n >> a >> b;

    cout << ((((a + b) % n + n - 1) % n) + 1) ;

    return 0;

}