#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define M 1000000007
#define INF 1000000007
typedef pair<lli,lli> ll;
#define mem(a,x) memset(a,x,sizeof(a))
lli n,m,k;
lli vis[100007];
lli dist[507][507];
lli path[207][207];
lli path1[207][207];
vector<int> v2;
vector<lli> v[100007];
lli x,y,c,z;
map<int,int> m1;
struct edge
{
    int a,b,cost;
};
lli c1=0;
lli p=0;
/*void djkstra(int x,vector<ll> v[])
{
    mem(vis,0);
    dist[x]=0;
    s2.insert({0,x});
    while(!s2.empty())
    {
        ll p=*s2.begin();
        s2.erase(s2.begin());
        x=p.second;
        if(vis[x])
        continue;
        vis[x]=1;
        for(int j=0;j<v[x].size();j++)
        {
            if(dist[v[x][j].second]>dist[x]+v[x][j].first)
            {
                dist[v[x][j].second]=dist[x]+v[x][j].first;
                s2.insert({dist[v[x][j].second],v[x][j].second});
                a[v[x][j].second]=x;
            }
        }
    }
}*/
lli parent[100007];
lli find(lli a)
{
    return a==parent[a]?a:parent[a]=find(parent[a]);
}
void dset(lli n)
{
    for(int j=0;j<=n;j++)
    parent[j]=j;
}
void unio(lli a,lli b,lli rank[])
{
    if(rank[find(a)]>rank[find(b)])
    parent[find(b)]=find(a);
    else if(rank[find(b)]>rank[find(a)])
    parent[find(a)]=find(b);
    else
    {
        parent[find(a)]=find(b);
        rank[find(b)]++;
    }
}
bool check(lli a,lli b)
{
    return find(a)==find(b);
}
lli q,u,v1,w,l,t1;
lli a[100007];
lli b[100007];
int re[100007];
int main()
{
    cin>>n;
    string s,s1;
    cin>>s>>s1;
    lli c=0;
    lli c1=0;
    lli c2=0;
    lli c3=0;
    for(int i=1;i<=n;i++)
    {
        if(s[i-1]=='1')
        c+=1;
        if(s[i-1]=='0'&&s1[i-1]=='0')
        c1+=1;
        if(s[i-1]=='1'&&s1[i-1]=='0')
        c2+=1;
        if(s[i-1]=='0'&&s1[i-1]!='0')
        c3+=1;
    }
    lli s2=0;
    s2=c*c1+(c3)*c2;
    cout<<s2;
}


#include<bits/stdc++.h>
using namespace std;long long n,a,b,c,d,i;string s,t;int main(){cin>>n>>s>>t;for(i=0;i<n;i++)if(s[i]=='0'){a++;if(t[i]=='1')b++;}else{c++;if(t[i]=='1')d++;}cout<<a*c-b*d;}


#include<bits/stdc++.h>
#define N 100100
using namespace std;
long long n,ans=0;
string a,b;
int t1,t2;//t1统计上下两位都是1的情况,t2统计上面是1且下面是0的情况
int main(){
	cin>>n>>a>>b;
	for(int i=0;i<n;i++){
		if(a[i]=='1') t1++;
		if(a[i]=='1'&&b[i]=='0') t2++;
    }
   // cout<<t1<<" "<<t2<<endl;
    for(int i=0;i<n;i++){
    	if(a[i]=='0'&&b[i]=='0') ans+=t1;
    	else if(a[i]=='0'&&b[i]=='1') ans+=t2;
	}
	cout<<ans;
	return 0;
}


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

int n;
long long num1, num0, c1, c0;
string a, b;

int main()
{
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++)
        if (a[i] == '1') num1++;
        else num0++;
    for (int i = 0; i < n; i++)
    {
        if (b[i] == '0')
            if (a[i] == '1') c0++;
            else c1++;
    }
    printf ("%lld", c0 * num0 + c1 * num1 - c1 * c0);
    return 0;
}


#include <a/stdc++.h>

int readbit()
{
    char ch=getchar();
    while(ch!='0' && ch!='1')ch=getchar();
    return ch-'0';
}

long long XX, XY, YX, YY;
int a[100005];
int n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)a[i]=readbit();
    for(int i=0;i<n;i++)
    {
        int x=readbit();
        if(x==0 && a[i]==0)YY++;
        else if(x==1 && a[i]==0) YX++;
        else if(x==1 && a[i]==1) XX++;
        else XY++;
    }
    cout<<XX*YY+XY*YX+XY*YY;
    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <set>
#include <climits>
#include <functional>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))	        \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef long long				LLONG;

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

char		chWordAArrays[100010];
char		chWordBArrays[100010];

int main(int argc, char* argv[])
{
	int				nWordLength;
	LLONG			llWordAOneCount				= 0;
	LLONG			llWordAZeroCount			= 0;
	LLONG			llWordBZeroOneCount			= 0;
	LLONG			llWordBZeroZeroCount		= 0;
	LLONG			llResult					= 0;

	cin >> nWordLength;
	cin >> chWordAArrays;
	cin >> chWordBArrays;

	for (int i = 0; i < nWordLength; i++)
	{
		if (chWordAArrays[i] == '0')
		{
			llWordAZeroCount++;
		}
		if (chWordAArrays[i] == '1')
		{
			llWordAOneCount++;
		}

		if (chWordBArrays[i] == '0' && chWordAArrays[i] == '1')
		{
			llWordBZeroOneCount++;
		}
		if (chWordBArrays[i] == '0' && chWordAArrays[i] == '0')
		{
			llWordBZeroZeroCount++;
		}
	}

	llResult = llWordBZeroZeroCount * llWordAOneCount + llWordBZeroOneCount * llWordAZeroCount
		- (llWordBZeroOneCount * llWordBZeroZeroCount);

	cout << llResult << endl;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char s1[200005];
char s2[200005];
unsigned a[5];
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s%s",s1,s2);
    for(int i=0;i<n;i++)
    {
        if(s1[i]=='0')
        {
		    if(s2[i]=='0') a[1]++;
            else a[2]++;
        }
        else
        {
            if(s2[i]=='1') a[3]++;
            else a[4]++;
        }
    }
    long long ans=0;
    ans=a[2]*a[4]+1ll*a[1]*a[3]+1ll*a[1]*a[4];
    printf("%lld\n",ans);
    return 0;
}


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


#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[100010];
long long aa,bb,ab,ba;
int main()
{
	int n;
	char ch;
	cin>>n;
	getchar();
	for(int i=1;i<=n;i++)
	{
		ch=getchar();
		s[i]=ch-48;
	}
	getchar();
	for(int i=1;i<=n;i++)
	{
		ch=getchar();
		int r=ch-48;
		if(r==1&&s[i]==1) aa++;
		else if(r==1&&s[i]==0) ba++;
		else if(r==0&&s[i]==0) bb++;
		else ab++;
	}
	getchar();
	printf("%lld\n",aa*bb+ab*ba+ab*bb);
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstdlib>
#include<queue>
#include<map>
using namespace std;
const int N=1e5+50;
long long ans,ans1,ans2,ans3,ans4,n;
char s[N],t[N];
int main()
{
    scanf("%d%s%s",&n,s,t);
    for(int i=0;i<n;i++)
	{
        if(s[i]=='0'&&t[i]=='1')ans1++;
        if(s[i]=='1'&&t[i]=='0')ans2++;
        if(s[i]=='1'&&t[i]=='1')ans3++;
        if(s[i]=='0'&&t[i]=='0')ans4++;
    }
    printf("%I64d\n",ans1*ans2+ans4*(ans2+ans3));
}


#include <bits/stdc++.h>
using namespace std;
const int N = 50050;
int a[N];
int b[N];
int ans;
int n;

int main(){
	cin>>n;
	int s=n/2;
	cout<<s*2;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long

int main()
{
	ll n,i,j,zxy,s[5]={0};
	string a,b;
	cin>>n;
	cin>>a>>b;
	for(i=0;i<n;i++)
	{
		if(a[i]=='0')
		{
			if(b[i]=='0')
				s[1]++;
			else
				s[2]++;
		}
		else
		{
			if(b[i]=='0')
				s[3]++;
			else
				s[4]++;
		}
	}
	zxy=s[1]*(s[3]+s[4])+s[2]*s[3];
	cout<<zxy<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define N 100100
using namespace std;
int n,ans=0;
string a,b;
int t1,t2;//t1统计上下两位都是1的情况,t2统计上面是1且下面是0的情况
int main(){
	cin>>n>>a>>b;
	for(int i=0;i<n;i++){
		if(a[i]=='1') t1++;
		if(a[i]=='1'&&b[i]=='0') t2++;
    }
   // cout<<t1<<" "<<t2<<endl;
    for(int i=0;i<n;i++){
    	if(a[i]=='0'&&b[i]=='0') ans+=t1;
    	else if(a[i]=='0'&&b[i]=='1') ans+=t2;
	}
	cout<<ans;
	return 0;
}


#include <cstring>
#include <string>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include<iomanip>
using namespace std;
const int maxn=1e5+100;
int n;
char s1[maxn],s2[maxn];
long long a,b,c,d,ans;
int read(){
    int x=0,f=1;
    char ch;
    while((ch=getchar())<'0'||ch>'9')
    {
        if(ch=='-')
        {
            f=-1;
        }
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-48;
        ch=getchar();
    }
    return x*f;
}
int main()
{
    //freopen("test.in","r",stdin);
    //freopen("test.out","w",stdout);
    scanf("%d",&n);
    getchar();
    scanf("%s%s",s1,s2);
    for(int i=0;i<n;i++)
    {
        if(s1[i]=='1'&&s2[i]=='1')
        {
            a++;
        }
        else if(s1[i]=='0'&&s2[i]=='0')
        {
            b++;
        }
        else if(s1[i]=='1'&&s2[i]=='0')
        {
            c++;
        }
        else if(s1[i]=='0'&&s2[i]=='1')
        {
            d++;
        }
    }
    cout<<(a+c)*b+c*d;
    return 0;
}


#include <iostream>
long long X,xx,y,Y;
int b[100005];
int n;
int readbit()
{
    char ch = getchar();
    while(ch != '0' && ch != '1') ch = getchar();
    return ch - '0';
}
int main()
{
    scanf("%d", &n);
    for(int i=1; i<=n; ++i) b[i] = readbit();
    for(int i=1; i<=n; ++i)
	{
        int x = readbit();
        if(x == 0 && b[i] == 0) ++Y;
        else if(x == 1 && b[i] == 0) ++y;
        else if(x ==1 && b[i] == 1) ++X;
        else ++xx;
    }
    printf("%lld", X * Y + xx * y + xx * Y);
    return 0;
}


#include <bits/stdc++.h>

long long XX, XY, YX, YY;
int bits[100005];
int n;

int readbit() {
    char ch = getchar();
    while(ch != '0' && ch != '1') ch = getchar();
    return ch - '0';
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) bits[i] = readbit();
    for (int i = 0; i < n; ++i) {
        int x = readbit();
        if (x == 0 && bits[i] == 0) ++YY;
        else if(x == 1 && bits[i] == 0) ++YX;
        else if(x ==1 && bits[i] == 1) ++XX;
        else ++XY;
    }
    printf("%lld", XX * YY + XY * YX + XY * YY);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }
#define f(i,l,n) for(int i = l;i < n;i++)
#define f0(i,n) f(i,0,n)
#define pb push_back
#define pob pop_back
#define makp make_pair
#define X first
#define Y second
#define all(x) x.begin(),x.end()
#define up(a,t) (upper_bound(all(a),t) - a.begin())
#define lb(a,t) (lower_bound(all(a),t) - a.begin())
vector<int> dx = {1, -1, 0, 0};
vector<int> dy = {0, 0, 1, -1};
typedef long long ll;
ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll ppow(ll x,int y){
    if (y == 0)
        return 1;
    if (y % 2 == 0)
        return ppow(x*x,y/2);
    else
        return ppow(x*x,y/2)*x;
}
int main(){
    int n;
    cin >> n;
    string a,b;
    cin >> a >> b;
    int t = 0,k = 0,e = 0,d = 0,ans = 0;
    for(int i = 0;i < n;i++){
        if(a[i] == '1' && b[i] == a[i]){
            t++;
        }
        if(a[i] == '1' && b[i] == '0'){
            k++;
        }
        if(a[i] == '0' && b[i] == '0'){
            e++;
        }
        if(a[i] == '0' && b[i] =='1'){
            d++;
        }

    }
    for(int i = 0;i < n;i++){
        if(a[i] == '0' && b[i] == '0'){
            if(t > 0){
                ans += 1;
            }
        }
        if(a[i] == '1' && b[i] == '0'){
            ans+=e+d;
        }
    }
    cout << ans;

}


#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }
#define f(i,l,n) for(int i = l;i < n;i++)
#define f0(i,n) f(i,0,n)
#define pb push_back
#define pob pop_back
#define makp make_pair
#define X first
#define Y second
#define all(x) x.begin(),x.end()
#define up(a,t) (upper_bound(all(a),t) - a.begin())
#define lb(a,t) (lower_bound(all(a),t) - a.begin())
vector<int> dx = {1, -1, 0, 0};
vector<int> dy = {0, 0, 1, -1};
typedef long long ll;
ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll ppow(ll x,int y){
    if (y == 0)
        return 1;
    if (y % 2 == 0)
        return ppow(x*x,y/2);
    else
        return ppow(x*x,y/2)*x;
}
int main(){
    int n;
    cin >> n;
    string a,b;
    cin >> a >> b;
    int t = 0,k = 0,e = 0,d = 0,ans = 0;
    for(int i = 0;i < n;i++){
        if(a[i] == '1' && b[i] == a[i]){
            t++;
        }
        if(a[i] == '1' && b[i] == '0'){
            k++;
        }
        if(a[i] == '0' && b[i] == '0'){
            e++;
        }
        if(a[i] == '0' && b[i] =='1'){
            d++;
        }

    }
    for(int i = 0;i < n;i++){
        if(a[i] == '0' && b[i] == '0'){
            ans+=t + k;
        }
        if(a[i] == '1' && b[i] == '0'){
            ans+=d;
        }
    }
    cout << ans;

}


#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }
#define f(i,l,n) for(int i = l;i < n;i++)
#define f0(i,n) f(i,0,n)
#define pb push_back
#define pob pop_back
#define makp make_pair
#define X first
#define Y second
#define all(x) x.begin(),x.end()
#define up(a,t) (upper_bound(all(a),t) - a.begin())
#define lb(a,t) (lower_bound(all(a),t) - a.begin())
vector<int> dx = {1, -1, 0, 0};
vector<int> dy = {0, 0, 1, -1};
typedef long long ll;
ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll ppow(ll x,int y){
    if (y == 0)
        return 1;
    if (y % 2 == 0)
        return ppow(x*x,y/2);
    else
        return ppow(x*x,y/2)*x;
}
int main(){
    int n;
    cin >> n;
    string a,b;
    cin >> a >> b;
    int t = 0,k = 0,e = 0,d = 0,ans = 0;
    for(int i = 0;i < n;i++){
        if(a[i] == '1' && b[i] == a[i]){
            t++;
        }
        if(a[i] == '1' && b[i] == '0'){
            k++;
        }
        if(a[i] == '0' && b[i] == '0'){
            e++;
        }
        if(a[i] == '0' && b[i] =='1'){
            d++;
        }

    }
    for(int i = 0;i < n;i++){
        if(a[i] == '0' && b[i] == '0'){
            ans+=t;
        }
        if(a[i] == '1' && b[i] == '0'){
            ans+=d;
        }
    }
    int h = k + e;
    ans += (h*(h-1))/2;
    cout << ans;

}


#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }
#define f(i,l,n) for(int i = l;i < n;i++)
#define f0(i,n) f(i,0,n)
#define pb push_back
#define pob pop_back
#define makp make_pair
#define X first
#define Y second
#define all(x) x.begin(),x.end()
#define up(a,t) (upper_bound(all(a),t) - a.begin())
#define lb(a,t) (lower_bound(all(a),t) - a.begin())
vector<int> dx = {1, -1, 0, 0};
vector<int> dy = {0, 0, 1, -1};
typedef long long ll;
ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll ppow(ll x,int y){
    if (y == 0)
        return 1;
    if (y % 2 == 0)
        return ppow(x*x,y/2);
    else
        return ppow(x*x,y/2)*x;
}
int main(){
    int n;
    cin >> n;
    string a,b;
    cin >> a >> b;
    int t = 0,k = 0,e = 0,d = 0,ans = 0;
    for(int i = 0;i < n;i++){
        if(a[i] == '1' && b[i] == a[i]){
            t++;
        }
        if(a[i] == '1' && b[i] == '0'){
            k++;
        }
        if(a[i] == '0' && b[i] == '0'){
            e++;
        }

    }
    for(int i = 0;i < n;i++){
        if(a[i] == '0' && b[i] == '0'){
            ans+=t+k;
        }
        if(a[i] == '1' && b[i] == '0'){
            ans+=e;
        }
    }
    cout << ans;

}


#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }
#define f(i,l,n) for(int i = l;i < n;i++)
#define f0(i,n) f(i,0,n)
#define pb push_back
#define pob pop_back
#define makp make_pair
#define X first
#define Y second
#define all(x) x.begin(),x.end()
#define up(a,t) (upper_bound(all(a),t) - a.begin())
#define lb(a,t) (lower_bound(all(a),t) - a.begin())
vector<int> dx = {1, -1, 0, 0};
vector<int> dy = {0, 0, 1, -1};
typedef long long ll;
ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll ppow(ll x,int y){
    if (y == 0)
        return 1;
    if (y % 2 == 0)
        return ppow(x*x,y/2);
    else
        return ppow(x*x,y/2)*x;
}
int main(){
    int n;
    cin >> n;
    string a,b;
    cin >> a >> b;
    ll t = 0,k = 0,e = 0,d = 0,ans = 0;
    for(int i = 0;i < n;i++){
        if(a[i] == '1' && b[i] == a[i]){
            t++;
        }
        if(a[i] == '1' && b[i] == '0'){
            k++;
        }
        if(a[i] == '0' && b[i] == '0'){
            e++;
        }
        if(a[i] == '0' && b[i] =='1'){
            d++;
        }

    }
    for(int i = 0;i < n;i++){
        if(a[i] == '0' && b[i] == '0'){
            ans+=t;
        }
        if(a[i] == '1' && b[i] == '0'){
            ans+=d + e;
        }
    }
    cout << ans;

}


#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }
#define f(i,l,n) for(int i = l;i < n;i++)
#define f0(i,n) f(i,0,n)
#define pb push_back
#define pob pop_back
#define makp make_pair
#define X first
#define Y second
#define all(x) x.begin(),x.end()
#define up(a,t) (upper_bound(all(a),t) - a.begin())
#define lb(a,t) (lower_bound(all(a),t) - a.begin())
vector<int> dx = {1, -1, 0, 0};
vector<int> dy = {0, 0, 1, -1};
typedef long long ll;
ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll ppow(ll x,int y){
    if (y == 0)
        return 1;
    if (y % 2 == 0)
        return ppow(x*x,y/2);
    else
        return ppow(x*x,y/2)*x;
}
int main(){
    int n;
    cin >> n;
    string a,b;
    cin >> a >> b;
    int t = 0,k = 0,e = 0,d = 0,ans = 0;
    for(int i = 0;i < n;i++){
        if(a[i] == '1' && b[i] == a[i]){
            t++;
        }
        if(a[i] == '1' && b[i] == '0'){
            k++;
        }
        if(a[i] == '0' && b[i] == '0'){
            e++;
        }
        if(a[i] == '0' && b[i] =='1'){
            d++;
        }

    }
    for(int i = 0;i < n;i++){
        if(a[i] == '0' && b[i] == '0'){
            ans+=t;
        }
        if(a[i] == '1' && b[i] == '0'){
            ans+=e+d;
        }
    }
    cout << ans;

}


#include <iostream>
using namespace std;

const int maxn = 100000;
char a[maxn + 1], b[maxn + 1];
int main()
{
	int n;
	while (cin >> n)
	{
		cin >> a >> b;
		int sum=0;
		int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
		for (int i = 0; i < n; i++)
		{
			if (a[i] == b[i])
			{
				if (a[i] == '0') sum1++;
				else sum2++;
			}
			else
			{
				if (a[i] == '0') sum3++;
				else sum4++;
			}
		}
		sum = sum1 * sum2 + sum1 * sum4 + sum4 * sum3;
		cout << sum << endl;
	}
}


#include <iostream>
using namespace std;

const int maxn = 100000;
char a[maxn + 1], b[maxn + 1];
int main()
{
	int n;
	while (cin >> n)
	{
		cin >> a >> b;
		int sum;
		int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
		for (int i = 0; i < n; i++)
		{
			if (a[i] == b[i])
			{
				if (a[i] == '0') sum1++;
				else sum2++;
			}
			else
			{
				if (a[i] == '0') sum3++;
				else sum4++;
			}
		}
		sum = sum1 * sum2 + sum1 * sum4 + sum4 * sum3;
		cout << sum << endl;
	}
}


#include <iostream>
using namespace std;

const int maxn = 100000;
char a[maxn + 1], b[maxn + 1];
int main()
{
	int n;
	while (cin >> n)
	{
		cin >> a >> b;
		int sum = n * (n - 1) / 2;
		for (int i = 0; i < n-1; i++)
		{
			for (int j = i + 1; j < n; j++)
			{
				if (a[i] == a[j] || b[i] == b[j])
				{
					if (b[i]  == '0'&&b[j]=='0' && a[i] != a[j]) continue;
					sum--;
				}
			}
		}
		cout << sum << endl;
	}
}


#include <iostream>
using namespace std;

const int maxn = 100000;
char a[maxn + 1], b[maxn + 1];
int main()
{
	int n;
	while (cin >> n)
	{
		cin >> a >> b;
		int sum=0;
		int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
		for (int i = 0; i < n; i++)
		{
			if (a[i] == b[i])
			{
				if (a[i] == '0') sum1++;
				else sum2++;
			}
			else
			{
				if (a[i] == '0') sum3++;
				else sum4++;
			}
		}
		sum = sum1 * sum2 + sum1 * sum4 + sum4 * sum3;
		cout << sum << endl;
	}
	return 0;
}


#include <iostream>
using namespace std;

const int maxn = 100000;
char a[maxn + 1], b[maxn + 1];
int main()
{
	int n;
	while (cin >> n)
	{
		cin >> a >> b;
		long long sum=0;
		long long sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
		for (int i = 0; i < n; i++)
		{
			if (a[i] == b[i])
			{
				if (a[i] == '0') sum1++;
				else sum2++;
			}
			else
			{
				if (a[i] == '0') sum3++;
				else sum4++;
			}
		}
		sum = sum1 * sum2 + sum1 * sum4 + sum4 * sum3;
		cout << sum << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pf printf
#define sf scanf

int main()
{
    int n;
    cin >> n;
    string a, b;
	cin >> a >> b;
	int u0n1=0,u1n0=0,u0n0=0,u1n1= 0;
	for(int i = 0; i < n;i++)
    {
		if(a[i] == '0' and b[i] == '1') u0n1++;
		else if(a[i] == '1' and b[i] == '0') u1n0++;
		else if(a[i] == '0' and b[i] == '0') u0n0++;
		else if(a[i] == '1' and b[i] == '1') u1n1++;
	}
	long long sum = 0;
	sum+=u0n1*u1n0;
	sum+=u0n0*u1n0;
	sum +=u0n0*u1n1;

	cout << sum << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pf printf
#define sf scanf

int main()
{
    int n;
    cin >> n;
    string a, b;
	cin >> a >> b;
	int u0n1=0,u1n0=0,u0n0=0,u1n1= 0;
	for(int i = 0; i < n;i++)
    {
		if(a[i] == '0' and b[i] == '1') u0n1++;
		else if(a[i] == '1' and b[i] == '0') u1n0++;
		else if(a[i] == '0' and b[i] == '0') u0n0++;
		else if(a[i] == '1' and b[i] == '1') u1n1++;
	}
	int sum = 0;
	sum+=u0n1*u1n0;
	sum+=u0n0*u1n0;
	sum +=u0n0*u1n1;

	cout << sum << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pf printf
#define sf scanf

int main()
{
    int n;
    cin >> n;
    string a, b;
	cin >> a >> b;
	long long u0n1=0,u1n0=0,u0n0=0,u1n1= 0;
	for(int i = 0; i < n;i++)
    {
		if(a[i] == '0' and b[i] == '1') u0n1++;
		else if(a[i] == '1' and b[i] == '0') u1n0++;
		else if(a[i] == '0' and b[i] == '0') u0n0++;
		else if(a[i] == '1' and b[i] == '1') u1n1++;
	}
	long long sum = 0;
	sum+=u0n1*u1n0;
	sum+=u0n0*u1n0;
	sum +=u0n0*u1n1;

	cout << sum << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pf printf
#define sf scanf

int main()
{
    int n;
    cin >> n;
    string a, b;
	cin >> a >> b;
	int u0n1=0,u1n0=0,u0n0=0,u1n1= 0;
	for(int i = 0; i < n;i++)
    {
		if(a[i] == '0' and b[i] == '1') u0n1++;
		else if(a[i] == '1' and b[i] == '0') u1n0++;
		else if(a[i] == '0' and b[i] == '0') u0n0++;
		else if(a[i] == '1' and b[i] == '1') u1n1++;
	}
	int sum = 0;
	sum = sum+u0n1*u1n0;
	sum = sum+u0n0*u1n0;
	sum = sum+u0n0*u1n1;

	cout << sum << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t1[110000];
int t2[110000];
int n;
int p,q;
set<pair<int,int> > s;
void check(string x);
int main(){
	cin>>n;
	char arr1[100020];
	char arr2[110000];
	cin>>arr1;
	cin>>arr2;
	check(arr1);
	for(int i=0;i<n;i++){
		if(arr2[i]=='0'){
			if(arr1[i]=='1'){
				for(int j=0;j<q;j++){
					int r=i;
					int y=t2[j];
					s.insert(make_pair(min(r,y),max(r,y)));
				}
			}else{
				for(int j=0;j<p;j++){
					int r=i;
					int y=t2[j];
					s.insert(make_pair(min(r,y),max(r,y)));
				}
			}
		}
	}
	cout<<s.size();
	return 0;
}
void check(string x){
	p=q=0;
	for(int i=0;i<n;i++){
		if(x[i]=='1'){
			t1[p]=i;
			p++;
		}else{
			t2[q]=i;
			q++;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
int t1[110000];
int t2[110000];
int n;
int p,q;
set<pair<int,int> > s;
void check(string x);
int main(){
	cin>>n;
	char arr1[100020];
	char arr2[110000];
	cin>>arr1;
	cin>>arr2;
	check(arr1);
	for(int i=0;i<n;i++){
		if(arr2[i]=='0'){
			if(arr1[i]=='1'){
				for(int j=0;j<q;j++){
					int r=i;
					int y=t2[j];
				//	cout<<r<<" "<<y<<endl;
					s.insert(make_pair(min(r,y),max(r,y)));
				}
			}else{
				for(int j=0;j<p;j++){
					int r=i;
					int y=t1[j];
				//	cout<<r<<" "<<y<<endl;
					s.insert(make_pair(min(r,y),max(r,y)));
				}
			}
		}
	}
	cout<<s.size();
	return 0;
}
void check(string x){
	p=q=0;
	for(int i=0;i<n;i++){
		if(x[i]=='1'){
			t1[p]=i;
			p++;
		}else{
			t2[q]=i;
			q++;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
vector<short>t1;
vector<short>t2;
int n;
int p,q;
set<pair<short,short> > s;
void check(string x);
int main(){
	cin>>n;
	char arr1[100020];
	char arr2[100020];
	cin>>arr1;
	cin>>arr2;
	check(arr1);
	for(int i=0;i<n;i++){
		if(arr2[i]=='0'){
			if(arr1[i]=='1'){
				for(int j=0;j<q;j++){
					int r=i;
					int y=t2[j];
				//	cout<<r<<" "<<y<<endl;
					s.insert(make_pair(min(r,y),max(r,y)));
				}
			}else{
				for(int j=0;j<p;j++){
					int r=i;
					int y=t1[j];
				//	cout<<r<<" "<<y<<endl;
					s.insert(make_pair(min(r,y),max(r,y)));
				}
			}
		}
	}
	cout<<s.size();
	return 0;
}
void check(string x){
	p=q=0;
	for(int i=0;i<n;i++){
		if(x[i]=='1'){
			t1.push_back(i);
			p++;
		}else{
			t2.push_back(i);
			q++;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
vector<int>t1;
vector<int>t2;
int n;
int p,q;
set<pair<int,int> > s;
void check(string x);
int main(){
	cin>>n;
	char arr1[100020];
	char arr2[100020];
	cin>>arr1;
	cin>>arr2;
	check(arr1);
	for(int i=0;i<n;i++){
		if(arr2[i]=='0'){
			if(arr1[i]=='1'){
				for(int j=0;j<q;j++){
					int r=i;
					int y=t2[j];
				//	cout<<r<<" "<<y<<endl;
					s.insert(make_pair(min(r,y),max(r,y)));
				}
			}else{
				for(int j=0;j<p;j++){
					int r=i;
					int y=t1[j];
				//	cout<<r<<" "<<y<<endl;
					s.insert(make_pair(min(r,y),max(r,y)));
				}
			}
		}
	}
	cout<<s.size();
	return 0;
}
void check(string x){
	p=q=0;
	for(int i=0;i<n;i++){
		if(x[i]=='1'){
			t1.push_back(i);
			p++;
		}else{
			t2.push_back(i);
			q++;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
int  checko();
int  checkz();
int n;
char str1[110000],str2[110000];
int main(){
	cin>>n;
	cin>>str1>>str2;
	int p=checko();
	int q=checkz();
	long long ans=0;
	for(int i=0;i<n;i++){
		if(str2[i]=='0'){
			if(str1[i]=='0'){
				ans+=p;
				q--;
			}else{
				ans+=q;
				p--;
			}
		}
	}
	cout<<ans;
	return 0;
}
int checko(){
	int ans=0;
	for(int i=0;i<n;i++){
		if(str1[i]=='1'){
			ans++;
		}
	}
	return ans;
}
int checkz(){
	int ans=0;
	for(int i=0;i<n;i++){
		if(str1[i]=='0'){
			ans++;
		}
	}
	return ans;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll ans=0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    int one=0,zero=0;
    int *a= new int[n];
    for(int i=0;i<n;i++)
    {
        a[i]= s[i]-48;
        if(a[i]==0)
        zero++;
        else
        one++;
    }
    cin >> s;
    ll cou=0;
    ll col=0;
    ll czl=0;
    ll czu=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1' && a[i]==1)
        col++;
        else if(s[i]=='1' && a[i]==0)
        czl++;
        else if(s[i]=='0' && a[i]==0)
        czu++;
        else if(s[i]=='0' && a[i]==1)
        cou++;
    }

    for(int i=0;i<n;i++)
    {
        if(s[i]=='1' && a[i]==1)
        ans+= czu;
        else if(s[i]=='1' && a[i]==0)
        ans+= cou;
        else if(s[i]=='0' && a[i]==0)
        ans+= (col + cou);
        else if(s[i]=='0' && a[i]==1)
        ans+= (czl + czu);
    }

    cout << ans/2;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll ans=0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    int one=0,zero=0;
    int *a= new int[n];
    for(int i=0;i<n;i++)
    {
        a[i]= s[i]-48;
        if(a[i]==0)
        zero++;
        else
        one++;
    }
    cin >> s;
    int cou=0;
    int col=0;
    int czl=0;
    int czu=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1' && a[i]==1)
        col++;
        else if(s[i]=='1' && a[i]==0)
        czl++;
        else if(s[i]=='0' && a[i]==0)
        czu++;
        else if(s[i]=='0' && a[i]==1)
        cou++;
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==1 && s[i]=='1')
            ans+=czu;
        else if(a[i]==0 && s[i]=='1')
            ans+=col;
        else if(a[i]==1 && s[i]=='0')
            ans+=(czl + czu);
        else if(a[i]==0 && s[i]=='0')
            ans+=(cou + col);
    }

    cout << ans/2;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll ans=0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    int one=0,zero=0;
    int *a= new int[n];
    for(int i=0;i<n;i++)
    {
        a[i]= s[i]-48;
        if(a[i]==0)
        zero++;
        else
        one++;
    }
    cin >> s;
    ll cou=0;
    ll col=0;
    ll czl=0;
    ll czu=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1' && a[i]==1)
        col++;
        else if(s[i]=='1' && a[i]==0)
        czl++;
        else if(s[i]=='0' && a[i]==0)
        czu++;
        else if(s[i]=='0' && a[i]==1)
        cou++;
    }

    cout << czu*(col+cou) + czl*cou;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll ans=0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    int one=0,zero=0;
    int *a= new int[n];
    for(int i=0;i<n;i++)
    {
        a[i]= s[i]-48;
        if(a[i]==0)
        zero++;
        else
        one++;
    }
    cin >> s;
    int cou=0;
    int col=0;
    int czl=0;
    int czu=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1' && a[i]==1)
        col++;
        else if(s[i]=='1' && a[i]==0)
        czl++;
        else if(s[i]=='0' && a[i]==0)
        czu++;
        else if(s[i]=='0' && a[i]==1)
        cou++;
    }

    cout << czu*(col+cou) + czl*cou;
}


// practice with kaiboy
import java.io.*;
import java.util.*;

public class CF1017C extends PrintWriter {
	CF1017C() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1017C o = new CF1017C(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		int m = 1;
		while (m * m < n)
			m++;
		int[] aa = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = i + 1;
		for (int h = 0; h < n; h += m)
			for (int l = h, r = Math.min(h + m, n) - 1; l < r; l++, r--) {
				int tmp = aa[l]; aa[l] = aa[r]; aa[r] = tmp;
			}
		for (int i = 0; i < n; i++)
			print(aa[i] + " ");
		println();
	}
}


import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.BufferedOutputStream;

public class ThePhoneNumber{

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static PrintWriter out;
    public static void main(String[] args){
        FastReader s = new FastReader();
        out=new PrintWriter (new BufferedOutputStream(System.out));
        int t = 1;
        for(int u = 0;u<t;u++){
            int n = s.nextInt();
            int sqrt = (int)Math.floor(Math.sqrt(n));
            int curr = n-sqrt+1;
            while(curr>0){
                for(int i = 0;i<sqrt;i++){
                    int temp = curr+i;
                    out.print(temp+ " ");
                }
                curr-=sqrt;
            }
            for(int i = 1;i<=n%sqrt;i++){
                out.print(i + " ");
            }
        }
        out.close();
    }

}


import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.BufferedOutputStream;

public class ThePhoneNumber{

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static PrintWriter out;
    public static void main(String[] args){
        FastReader s = new FastReader();
        out=new PrintWriter (new BufferedOutputStream(System.out));
        int t = 1;
        for(int u = 0;u<t;u++){
            int n = s.nextInt();
            int i = (n/2)+1;
            while(i<=n){
                out.print(i + " ");
                i++;
            }
            int j = 1;
            while(j<=n/2){
                out.print(j + " ");
                j++;
            }
        }
        out.close();
    }

}


import java.util.*;
import java.io.*;

public class File {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		if (n == 1) {
			System.out.println(1);
			return;
		}
		else if (n == 2) {
			System.out.println(1 + " " + 2);
			return;
		}

		// All increasing or all decreasing.
		int min = n + 1;
		int groupSize = n; // Best size of one increasing group of numbers.
		int groupCount = 1; // Best number of groups.

		// Answer is smallest sum equal to:
		// (# groups) + (max size of a group).
		for (int size = n; size >= 1; size--) {
			int groups = (int)Math.ceil((double)n / (double)size);

			if (size + groups < min) {
				min = size + groups;
				groupSize = size;
				groupCount = groups;
			}
		}

		while (n > 0) {
			int m = Math.min(n, groupSize);

			for (int i = n - m + 1; i <= n; i++) {
				System.out.print(i + " ");
			}

			n -= m;
		}
	}
}


import java.util.*;
import java.io.*;

public class File {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

		// Secret value equals:
		// Sum of length of longest increasing subsequence.
		// and length of longest decreasing subsequence.
		// Minimize this sum.

		int n = sc.nextInt();

		if (n == 1) {
			System.out.println(1);
			return;
		}
		else if (n == 2) {
			System.out.println(1 + " " + 2);
			return;
		}

		// 5 3 4 1 2 = 3 + 2
		// 3 4 1 2 5 = 3 + 2
		while (n > 0) {
			int a = n;
			int b = n - 1;
			n -= 2;

			if (a > 0 && b > 0) {
				System.out.print(b + " ");
				System.out.print(a + " " );
			}
			else {
				System.out.print(a + " ");
			}
		}
	}
}


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

const int mod = 1e9 + 7;

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)

#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

const int limit=1e6+10;
vl prime[limit+1];

void seive(ll limit)
{
  ll i,j;
  bool mark[limit+1];
  memset(mark,true,sizeof(mark));
  for(i=2;i<=limit;i++)
  {
    if(mark[i])
    {
      for(j=i;j<=limit;j+=i)
      {
        mark[j]=false;
        prime[j].pb(i);
      }
    }
  }

  // for(i=2;i<=limit;i++)
  // {
  //   if(mark[i])
  //   {
  //     prime.pb(i);
  //     // cout << i << " ";
  //   }
  // }
  // cout << endl;
  return ;
}
/* vector< vector<pair<ll,ll> >> g;
vl d,d1,dn;
vector<bool> vis(3e5+6,false);
void dfs(ll x,ll dist=0)
{
  vis[x]=true;
  ll i,j;
  d[x]=dist;
  for(auto k=g[x].begin();k!=g[x].end();k++)
  {
    if(!vis[k->first])
    {
      vis[k->first]=true;
      dfs(k->first,dist+k->second);
    }
  }
  return ;
}
 ll sum123[2][(ll)3e5+6],sum321[2][(ll)3e5+6],sum111[2][(ll)3e5+6];
*/
const ll M=1e9+7;
ll power(ll a,ll n)
{
  if(n==0)
    return 1;
  else if(n==1)
  return n;
  ll z=power(a,n/2);
  if(n&1)
    return ((z%M*z%M)%M*a%M)%M;
  else
    return (z%M*z%M)%M;
}
bool sortbysecdesc(const pair<int,int> &a,
                   const pair<int,int> &b)
{
       return a.second>b.second;
}

vl a(100005,0);
int main()
{
 ios_base::sync_with_stdio(0);
 ll n;
 cin >> n;
 ll i,j,k;
 ll s=sqrt(n);

 ll last=0;
// cout << s << " \n";
for(i=n;i>=0;i-=s)
{
  for(j=max(0ll,i-s);j<i;j++)
  {
    a[j]=++last;
  }
}

 fr(i,0,n-1)
  cout << a[i] << " ";

  return 0;
}


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

const int mod = 1e9 + 7;

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)

#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

const int limit=1e6+10;
vl prime[limit+1];

void seive(ll limit)
{
  ll i,j;
  bool mark[limit+1];
  memset(mark,true,sizeof(mark));
  for(i=2;i<=limit;i++)
  {
    if(mark[i])
    {
      for(j=i;j<=limit;j+=i)
      {
        mark[j]=false;
        prime[j].pb(i);
      }
    }
  }

  // for(i=2;i<=limit;i++)
  // {
  //   if(mark[i])
  //   {
  //     prime.pb(i);
  //     // cout << i << " ";
  //   }
  // }
  // cout << endl;
  return ;
}
/* vector< vector<pair<ll,ll> >> g;
vl d,d1,dn;
vector<bool> vis(3e5+6,false);
void dfs(ll x,ll dist=0)
{
  vis[x]=true;
  ll i,j;
  d[x]=dist;
  for(auto k=g[x].begin();k!=g[x].end();k++)
  {
    if(!vis[k->first])
    {
      vis[k->first]=true;
      dfs(k->first,dist+k->second);
    }
  }
  return ;
}
 ll sum123[2][(ll)3e5+6],sum321[2][(ll)3e5+6],sum111[2][(ll)3e5+6];
*/
const ll M=1e9+7;
ll power(ll a,ll n)
{
  if(n==0)
    return 1;
  else if(n==1)
  return n;
  ll z=power(a,n/2);
  if(n&1)
    return ((z%M*z%M)%M*a%M)%M;
  else
    return (z%M*z%M)%M;
}
bool sortbysecdesc(const pair<int,int> &a,
                   const pair<int,int> &b)
{
       return a.second>b.second;
}
int main()
{
 ios_base::sync_with_stdio(0);
 ll n;
 cin >> n;
 ll i,j;
 vl a(n,0);
 fr(i,0,n-1)
 {
     a[i]=i+1;
     i++;
 }
 fr(i,1,n-1)
 {
     a[i]=2*(n/2)-(i-1);
     i++;
 }
 fr(i,0,n-1)
    cout << a[i] << " ";
  return 0;
}


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

const int mod = 1e9 + 7;

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)

#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

const int limit=1e6+10;
vl prime[limit+1];

void seive(ll limit)
{
  ll i,j;
  bool mark[limit+1];
  memset(mark,true,sizeof(mark));
  for(i=2;i<=limit;i++)
  {
    if(mark[i])
    {
      for(j=i;j<=limit;j+=i)
      {
        mark[j]=false;
        prime[j].pb(i);
      }
    }
  }

  // for(i=2;i<=limit;i++)
  // {
  //   if(mark[i])
  //   {
  //     prime.pb(i);
  //     // cout << i << " ";
  //   }
  // }
  // cout << endl;
  return ;
}
/* vector< vector<pair<ll,ll> >> g;
vl d,d1,dn;
vector<bool> vis(3e5+6,false);
void dfs(ll x,ll dist=0)
{
  vis[x]=true;
  ll i,j;
  d[x]=dist;
  for(auto k=g[x].begin();k!=g[x].end();k++)
  {
    if(!vis[k->first])
    {
      vis[k->first]=true;
      dfs(k->first,dist+k->second);
    }
  }
  return ;
}
 ll sum123[2][(ll)3e5+6],sum321[2][(ll)3e5+6],sum111[2][(ll)3e5+6];
*/
const ll M=1e9+7;
ll power(ll a,ll n)
{
  if(n==0)
    return 1;
  else if(n==1)
  return n;
  ll z=power(a,n/2);
  if(n&1)
    return ((z%M*z%M)%M*a%M)%M;
  else
    return (z%M*z%M)%M;
}
bool sortbysecdesc(const pair<int,int> &a,
                   const pair<int,int> &b)
{
       return a.second>b.second;
}
int main()
{
 ios_base::sync_with_stdio(0);
 ll n;
 cin >> n;
 vl a(n,0);
 ll i,j,k;
 ll s=sqrt(n);
 ll last=0;
// cout << s << " \n";
  for(j=s-1;j>=0;--j)
{
  i=n%s+s*(j);
  k=i;
  // cout << i << "\n";
  while(i-k<s)
  {
    a[i]=++last;
    i++;
  }
}
  fr(j,0,n-1)
  {
    if(a[j]==0)
      a[j]=++last;
  }
 fr(i,0,n-1)
  cout << a[i] << " ";

  return 0;
}


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

const int mod = 1e9 + 7;

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)

#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

const int limit=1e6+10;
vl prime[limit+1];

void seive(ll limit)
{
  ll i,j;
  bool mark[limit+1];
  memset(mark,true,sizeof(mark));
  for(i=2;i<=limit;i++)
  {
    if(mark[i])
    {
      for(j=i;j<=limit;j+=i)
      {
        mark[j]=false;
        prime[j].pb(i);
      }
    }
  }

  // for(i=2;i<=limit;i++)
  // {
  //   if(mark[i])
  //   {
  //     prime.pb(i);
  //     // cout << i << " ";
  //   }
  // }
  // cout << endl;
  return ;
}
/* vector< vector<pair<ll,ll> >> g;
vl d,d1,dn;
vector<bool> vis(3e5+6,false);
void dfs(ll x,ll dist=0)
{
  vis[x]=true;
  ll i,j;
  d[x]=dist;
  for(auto k=g[x].begin();k!=g[x].end();k++)
  {
    if(!vis[k->first])
    {
      vis[k->first]=true;
      dfs(k->first,dist+k->second);
    }
  }
  return ;
}
 ll sum123[2][(ll)3e5+6],sum321[2][(ll)3e5+6],sum111[2][(ll)3e5+6];
*/
const ll M=1e9+7;
ll power(ll a,ll n)
{
  if(n==0)
    return 1;
  else if(n==1)
  return n;
  ll z=power(a,n/2);
  if(n&1)
    return ((z%M*z%M)%M*a%M)%M;
  else
    return (z%M*z%M)%M;
}
bool sortbysecdesc(const pair<int,int> &a,
                   const pair<int,int> &b)
{
       return a.second>b.second;
}
int main()
{
 ios_base::sync_with_stdio(0);
 ll n;
 cin >> n;
 ll i,j;
 vl a(n,0);
 fr(i,0,n-1)
 {
     a[i]=i+1;
     i++;
 }
 fr(i,1,n-1)
 {
     a[i]=2*(n/2)-(i-1);
     i++;
 }
 a[0]=a[1];
 a[1]=1;
 fr(i,0,n-1)
    cout << i+1 << " ";
  return 0;
}


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

const int mod = 1e9 + 7;

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)

#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

const int limit=1e6+10;
vl prime[limit+1];

void seive(ll limit)
{
  ll i,j;
  bool mark[limit+1];
  memset(mark,true,sizeof(mark));
  for(i=2;i<=limit;i++)
  {
    if(mark[i])
    {
      for(j=i;j<=limit;j+=i)
      {
        mark[j]=false;
        prime[j].pb(i);
      }
    }
  }

  // for(i=2;i<=limit;i++)
  // {
  //   if(mark[i])
  //   {
  //     prime.pb(i);
  //     // cout << i << " ";
  //   }
  // }
  // cout << endl;
  return ;
}
/* vector< vector<pair<ll,ll> >> g;
vl d,d1,dn;
vector<bool> vis(3e5+6,false);
void dfs(ll x,ll dist=0)
{
  vis[x]=true;
  ll i,j;
  d[x]=dist;
  for(auto k=g[x].begin();k!=g[x].end();k++)
  {
    if(!vis[k->first])
    {
      vis[k->first]=true;
      dfs(k->first,dist+k->second);
    }
  }
  return ;
}
 ll sum123[2][(ll)3e5+6],sum321[2][(ll)3e5+6],sum111[2][(ll)3e5+6];
*/
const ll M=1e9+7;
ll power(ll a,ll n)
{
  if(n==0)
    return 1;
  else if(n==1)
  return n;
  ll z=power(a,n/2);
  if(n&1)
    return ((z%M*z%M)%M*a%M)%M;
  else
    return (z%M*z%M)%M;
}
bool sortbysecdesc(const pair<int,int> &a,
                   const pair<int,int> &b)
{
       return a.second>b.second;
}
int main()
{
 ios_base::sync_with_stdio(0);
 ll n;
 cin >> n;
 ll i,j;
 vl a(n,0);
// fr(i,0,n-1)
// {
//     a[i]=i+1;
//     i++;
// }
// fr(i,1,n-1)
// {
//     a[i]=2*(n/2)-(i-1);
//     i++;
// }
  j=0;
  fr(i,0,n-1)
  {
    if(i<n/2)
    {
      a[i]=1+(n+1)/2+i;
    }
    else
    {
      a[i]=++j;
    }
  }
  fr(i,0,n-1)
    cout << a[i] << " ";
  return 0;
}


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

const int mod = 1e9 + 7;

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)

#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

const int limit=1e6+10;
vl prime[limit+1];

void seive(ll limit)
{
  ll i,j;
  bool mark[limit+1];
  memset(mark,true,sizeof(mark));
  for(i=2;i<=limit;i++)
  {
    if(mark[i])
    {
      for(j=i;j<=limit;j+=i)
      {
        mark[j]=false;
        prime[j].pb(i);
      }
    }
  }

  // for(i=2;i<=limit;i++)
  // {
  //   if(mark[i])
  //   {
  //     prime.pb(i);
  //     // cout << i << " ";
  //   }
  // }
  // cout << endl;
  return ;
}
/* vector< vector<pair<ll,ll> >> g;
vl d,d1,dn;
vector<bool> vis(3e5+6,false);
void dfs(ll x,ll dist=0)
{
  vis[x]=true;
  ll i,j;
  d[x]=dist;
  for(auto k=g[x].begin();k!=g[x].end();k++)
  {
    if(!vis[k->first])
    {
      vis[k->first]=true;
      dfs(k->first,dist+k->second);
    }
  }
  return ;
}
 ll sum123[2][(ll)3e5+6],sum321[2][(ll)3e5+6],sum111[2][(ll)3e5+6];
*/
const ll M=1e9+7;
ll power(ll a,ll n)
{
  if(n==0)
    return 1;
  else if(n==1)
  return n;
  ll z=power(a,n/2);
  if(n&1)
    return ((z%M*z%M)%M*a%M)%M;
  else
    return (z%M*z%M)%M;
}
bool sortbysecdesc(const pair<int,int> &a,
                   const pair<int,int> &b)
{
       return a.second>b.second;
}
int main()
{
 ios_base::sync_with_stdio(0);
 ll n;
 cin >> n;
 ll i,j;
 vl a(n,0);
 fr(i,0,n-1)
 {
     a[i]=i+1;
     i++;
 }
 fr(i,1,n-1)
 {
     a[i]=2*(n/2)-(i-1);
     i++;
 }
 a[0]=a[1];
 a[1]=1;
 fr(i,0,n-1)
    cout << a[i] << " ";
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <numeric>
using namespace std;
#define  PB push_back
#define  pb pop_back
#define  MP make_pair
#define  endl "\n"
#define  pi 3.1415926535
using LL =long long;
const LL INF = 1e9;
const int N = 2e5+10;
const LL MOD = 1e9+7;

void ArrayIn (int size, int a []) {
    for (int i = 0; i < size; i++)
        cin >> a [i];
}
void ArrayOut (int size, int a []) {
    for (int i = 0; i < size; i++)
        cout << a [i] << " ";
    cout << endl;
}
             //😘😘
int main () {
    int n; cin >> n;
    while (n) {
        cout << n-- << " ";
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <numeric>
using namespace std;
#define  PB push_back
#define  pb pop_back
#define  MP make_pair
#define  endl "\n"
#define  pi 3.1415926535
using LL =long long;
const LL INF = 1e9;
const int N = 2e5+10;
const LL MOD = 1e9+7;

void ArrayIn (int size, int a []) {
    for (int i = 0; i < size; i++)
        cin >> a [i];
}
void ArrayOut (int size, int a []) {
    for (int i = 0; i < size; i++)
        cout << a [i] << " ";
    cout << endl;
}
             //😘😘
int main () {
    int n; cin >> n;
    int i = n, j = 1;
    while (j <= i) {
        cout << i-- << " ";
        if (i < j) break;
        cout << j++ << " ";
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <numeric>
using namespace std;
#define  PB push_back
#define  pb pop_back
#define  MP make_pair
#define  endl "\n"
#define  pi 3.1415926535
using LL =long long;
const LL INF = 1e9;
const int N = 2e5+10;
const LL MOD = 1e9+7;

void ArrayIn (int size, int a []) {
    for (int i = 0; i < size; i++)
        cin >> a [i];
}
void ArrayOut (int size, int a []) {
    for (int i = 0; i < size; i++)
        cout << a [i] << " ";
    cout << endl;
}
             //😘😘
int main () {
    int n, i; cin >> n;
    for (i = 1; i <= n/2; i++) cout << i << " ";
    while (n >= i) cout << n-- << " ";
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <numeric>
using namespace std;
#define  PB push_back
#define  pb pop_back
#define  MP make_pair
#define  endl "\n"
#define  pi 3.1415926535
using LL =long long;
const LL INF = 1e9;
const int N = 2e5+10;
const LL MOD = 1e9+7;

void ArrayIn (int size, int a []) {
    for (int i = 0; i < size; i++)
        cin >> a [i];
}
void ArrayOut (int size, int a []) {
    for (int i = 0; i < size; i++)
        cout << a [i] << " ";
    cout << endl;
}

int main () {
    int n, i; cin >> n;
    int chunk_size = sqrt (n);
    for (i = 0; i < n; i+=chunk_size) {
        int p = min (i+chunk_size, n);
        while (p > i) cout << p-- << " ";
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <numeric>
using namespace std;
#define  PB push_back
#define  pb pop_back
#define  MP make_pair
#define  endl "\n"
#define  pi 3.1415926535
using LL =long long;
const LL INF = 1e9;
const int N = 2e5+10;
const LL MOD = 1e9+7;

void ArrayIn (int size, int a []) {
    for (int i = 0; i < size; i++)
        cin >> a [i];
}
void ArrayOut (int size, int a []) {
    for (int i = 0; i < size; i++)
        cout << a [i] << " ";
    cout << endl;
}
             //😘😘
int main () {
    int n, i; cin >> n;
    for (i = n/2; i > 0; i--) cout << i << " ";
    i = n/2;
    while (n > i) cout << n-- << " ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define pi (atan(1)*4)
#define mod 1000000007
// ||
//const int N = 2e5 +9;
int main(){
    int n;
    cin>>n;
    int mn = 1e9;
    int j = -1;
    if(n == 3){
        cout<<"3 1 2";
        return 0;
    }
    for(int i =1;i<=n;i++){
        if(i + n/i + (n%i != 0)  < mn){
            mn = i + n/i + (n%i != 0) ;
            j = i;
        }
    }
        vector<vector<int>>v;
        int x = 1;
        for(int i = 0;i<n/j;i++){
            vector<int>c;
            for(int jj = 0 ; jj<j;jj++){
                c.push_back(x++);
            }
            v.push_back(c);
        }
        vector<int>c;
        while(x <= n){
            c.push_back(x++);
        }
        v.push_back(c);
        reverse(v.begin(),v.end());
        for(auto i : v){
            for(auto ii :i){
                cout<<ii<<' ';
            }
        }
    return 0;
}


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

int main() {
    int n;
    scanf("%d",&n);
    if(n%2 == 0)
        for(int i = 1;i<=n;i+=2){
            cout<<i+1<<' '<<i<<' ';
        }
    else
        for(int i = 1;i<n-3;i+=2){
            cout<<i+1<<' '<<i<<' ';
        }
        cout<<n<<' '<<n-1<<' '<<n-2;
    return 0;
}
//1 2 3 4 5


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define pi (atan(1)*4)
#define mod 1000000007
// ||
//const int N = 2e5 +9;
int main(){
    int n;
    cin>>n;
    int mn = 1e9;
    int j = -1;
    for(int i =2;i*i<=n;i++){
        if(n%i == 0){
            if(i + n/i < mn){
                mn = i + n/i;
                j = i;
            }
        }
    }
    if(j != -1){
        vector<vector<int>>v;
        int x = 1;
        for(int i = 0;i<n/j;i++){
            vector<int>c;
            for(int jj = 0 ; jj<j;jj++){
                c.push_back(x++);
            }
            v.push_back(c);
        }
        reverse(v.begin(),v.end());
        for(auto i : v){
            for(auto ii :i){
                cout<<ii<<' ';
            }
        }
    }else{
        vector<int>v;
        int x = 1;
        for(int i = 0;i<n/2;i++){
            v.push_back(x++);
        }
        for(int i = 0;i<n/2 + n%2;i++){
            cout<<x++<<' ';
        }
        for(auto i : v){
            cout<<i<<' ';
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define pi (atan(1)*4)
#define mod 1000000007
// ||
//const int N = 2e5 +9;
int main(){
    int n;
    cin>>n;
    vector<int>v;
    int x = 1;
    for(int i = 0;i<n/2;i++){
        v.push_back(x++);
    }
    for(int i = 0;i<n/2 + n%2;i++){
        cout<<x++<<' ';
    }
    for(auto i : v){
        cout<<i<<' ';
    }
    return 0;
}


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

int main() {
    int n;
    scanf("%d",&n);
    for(int i = 1;i<=n;i+=2){
        if(n%2 != 0 && i == n){
            cout<<n;
            break;
        }else{
            cout<<i+1<<' '<<i<<' ';
        }
    }
    return 0;
}
//1 2 3 4 5


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define pi (atan(1)*4)
#define mod 1000000007
// ||
//const int N = 2e5 +9;
int main(){
    int n;
    cin>>n;
    int mn = 1e9;
    int j = -1;
    if(n == 3){
        cout<<"3 1 2";
        return 0;
    }
    for(int i =2;i*i<=n;i++){
        if(n%i == 0){
            if(i + n/i < mn){
                mn = i + n/i;
                j = i;
            }
        }
    }
    if(j != -1){
        vector<vector<int>>v;
        int x = 1;
        for(int i = 0;i<n/j;i++){
            vector<int>c;
            for(int jj = 0 ; jj<j;jj++){
                c.push_back(x++);
            }
            v.push_back(c);
        }
        reverse(v.begin(),v.end());
        for(auto i : v){
            for(auto ii :i){
                cout<<ii<<' ';
            }
        }
    }else{
        vector<int>v;
        int x = 1;
        for(int i = 0;i<n/2;i++){
            v.push_back(x++);
        }
        for(int i = 0;i<n/2 + n%2;i++){
            cout<<x++<<' ';
        }
        for(auto i : v){
            cout<<i<<' ';
        }
    }
    return 0;
}


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

int main() {
    int n;
    scanf("%d",&n);
    if(n%2 == 0)
        for(int i = 1;i<=n;i+=2){
            cout<<i+1<<' '<<i<<' ';
        }
    else{
        for(int i = 1;i<n-3;i+=2){
            cout<<i+1<<' '<<i<<' ';
        }
        cout<<n<<' '<<n-1<<' '<<n-2;
    }
    return 0;
}
//1 2 3 4 5


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

#define fio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
// #define double long double
// #define mp make_pair
// #define pb push_back
// //Upper case English alphabet to lower case ch |= ' ';
// //Lower case English alphabet to upper case ch &= '_’ ;

int M=(int)1e5+1,t=0;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int digits(int n){return floor(log10(n))+1 ;}
bool ispoweroftwo (int x) { return x && (!(x&(x-1))); }
// vector<int> vis,parent,ti,tout,dis;
// vector<vector<int> > adj;

// void dfs(int v){
//     vis[v]=1;
//     for(int i:adj[v]){
//         if(vis[i]){
//             t=1;
//             return ;
//         }
//             //dis[i]=1+dis[v];
//             //parent[i]=v;
//             vis[i]=1;
//             dfs(i);

//     }
//     return ;

// }

signed main(){
    fio;
    int n;
    cin>>n;
    if(n==1) {
        cout<<1<<endl;return 0;
    }
    int x=2;
    while(n%x!=0){
        x++;
    }
    if(n==x) x=2;
    int nn=n-x+1;
    int cnt=0;
    while(nn>1){
        int p=nn;
        for(int i=0;i<x;i++){
            cout<<p<<" ";
            p++;
            cnt++;
        }
        nn-=x;
    }
    cnt=n-cnt;
    x=1;
    while(cnt--){
        cout<<x<<" ";
        x++;
    }
    cout<<endl;

}


package main

import (
	"container/heap"
	"fmt"
    "bufio"
    "os"
)

var (
   reader = bufio.NewReader(os.Stdin)
)

type entry struct {
	cost, pos int
}

type myQueue []*entry

func (pq myQueue) Len() int {
	return len(pq)
}

func (pq myQueue) Less(i, j int) bool {
	return pq[i].cost < pq[j].cost
}

func (pq myQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *myQueue) Push(x interface{}) {
	item := x.(*entry)
	*pq = append(*pq, item)
}

func (pq *myQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

func Qamount(a []byte, n int) int {
	i, res := 0, 0
	for a[i] != 0 {
		i++
        if a[i] == '?' {
           res++
        }
	}
    return res
}

func main() {
	const inf = 1e9
	myQ := &myQueue{}
	heap.Init(myQ)
	var tempTab string
	cval, oval := make([]int, 60000), make([]int, 60000)
	tab := make([]byte, 60000)
	fmt.Fscanf(reader, "%v", &tempTab)
	n := len(tempTab)
	for i := 0; i < n; i++ {
		tab[i] = tempTab[i]
	}
	//fmt.Printf("%v\n", tab)
	m := Qamount(tab, n)
//    fmt.Println(m)
	for i := 0; i < m; i++ {
		fmt.Fscan(reader, &oval[i], &cval[i])
	}
//    for i := 0; i < m; i++ {
//       fmt.Println(i, oval[i], cval[i])
//    }
	bal, res, pos := 0, int64(0), 0
	for i := 0; i < n; i++ {
		switch tab[i] {
		case '(':
			bal++
		case ')':
			bal--
		default:
//            fmt.Println("res += ", int64(cval[pos]))
			res += int64(cval[pos])
			tab[i] = ')'
			bal--
			heap.Push(myQ, &entry{oval[pos] - cval[pos], i})
			pos++
		}
		if bal < 0 {
			if myQ.Len() > 0 {
				temp := heap.Pop(myQ).(*entry)
				//fmt.Printf("  %v\n", heap.Pop(myQ))
				res += int64(temp.cost)
				tab[temp.pos] = '('
				bal += 2
			} else {
				bal = inf
				break
			}
		}
	}
    tempTab = string(tab[:n])
	if bal == 0 {
		fmt.Printf("%v\n%v\n", res, tempTab)
	} else {
		fmt.Printf("-1\n")
	}
}


package main

import (
	"container/heap"
	"fmt"
)

type entry struct {
	cost, pos int
}

type myQueue []*entry

func (pq myQueue) Len() int {
	return len(pq)
}

func (pq myQueue) Less(i, j int) bool {
	return pq[i].cost < pq[j].cost
}

func (pq myQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *myQueue) Push(x interface{}) {
	item := x.(*entry)
	*pq = append(*pq, item)
}

func (pq *myQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

func Qamount(a []byte, n int) int {
	i := 0
	for a[i] != 0 {
		i++
	}
	return i
}

func main() {
	const inf = 1e9
	myQ := &myQueue{}
	heap.Init(myQ)
	var tempTab string
	cval, oval := make([]int, 60000), make([]int, 60000)
	tab := make([]byte, 60000)
	fmt.Scanf("%v", &tempTab)
	n := len(tempTab)
	for i := 0; i < n; i++ {
		tab[i] = tempTab[i]
	}
	//fmt.Printf("%v\n", tab)
	m := Qamount(tab, n)
	for i := 0; i < m; i++ {
		fmt.Scanf("%d%d", &oval[i], &cval[i])
	}
	bal, res, pos := 0, int64(0), 0
	for i := 0; i < n; i++ {
		switch tab[i] {
		case '(':
			bal++
		case ')':
			bal--
		default:
			res += int64(cval[pos])
			tab[i] = ')'
			bal--
			heap.Push(myQ, &entry{oval[pos] - cval[pos], i})
			pos++
		}
		if bal < 0 {
			if myQ.Len() > 0 {
				temp := heap.Pop(myQ).(*entry)
				//fmt.Printf("  %v\n", heap.Pop(myQ))
				res += int64(temp.cost)
				tab[temp.pos] = '('
				bal += 2
			} else {
				bal = inf
				break
			}
		}
	}
    tempTab = string(tab[:n])
	if bal == 0 {
		fmt.Printf("%v\n%v\n", res, tempTab)
	} else {
		fmt.Printf("-1\n")
	}
}


package main

import (
	"container/heap"
	"fmt"
    "bufio"
    "os"
)

var (
   reader = bufio.NewReader(os.Stdin)
)

type entry struct {
	cost, pos int
}

type myQueue []*entry

func (pq myQueue) Len() int {
	return len(pq)
}

func (pq myQueue) Less(i, j int) bool {
	return pq[i].cost < pq[j].cost
}

func (pq myQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *myQueue) Push(x interface{}) {
	item := x.(*entry)
	*pq = append(*pq, item)
}

func (pq *myQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

func Qamount(a []byte, n int) int {
	res := 0
    for i := 0; i < n; i++ {
        if a[i] == '?' {
           res++
        }
	}
    return res
}

func main() {
	const inf = 1e9
	myQ := &myQueue{}
	heap.Init(myQ)
	var tempTab string
	cval, oval := make([]int, 60000), make([]int, 60000)
	tab := make([]byte, 60000)
	fmt.Fscanf(reader, "%v", &tempTab)
	n := len(tempTab)
	for i := 0; i < n; i++ {
		tab[i] = tempTab[i]
	}
	//fmt.Printf("%v\n", tab)
	m := Qamount(tab, n)
//    fmt.Println(m)
	for i := 0; i < m; i++ {
		fmt.Fscan(reader, &oval[i], &cval[i])
	}
//    for i := 0; i < m; i++ {
//       fmt.Println(i, oval[i], cval[i])
//    }
	bal, res, pos := 0, int64(0), 0
	for i := 0; i < n; i++ {
		switch tab[i] {
		case '(':
			bal++
		case ')':
			bal--
		default:
//            fmt.Println("res += ", int64(cval[pos]))
			res += int64(cval[pos])
			tab[i] = ')'
			bal--
			heap.Push(myQ, &entry{oval[pos] - cval[pos], i})
			pos++
		}
		if bal < 0 {
			if myQ.Len() > 0 {
				temp := heap.Pop(myQ).(*entry)
				//fmt.Printf("  %v\n", heap.Pop(myQ))
				res += int64(temp.cost)
				tab[temp.pos] = '('
				bal += 2
			} else {
				bal = inf
				break
			}
		}
	}
    tempTab = string(tab[:n])
	if bal == 0 {
		fmt.Printf("%v\n%v\n", res, tempTab)
	} else {
		fmt.Printf("-1\n")
	}
}


package main

import (
   "container/heap"
   "fmt"
)

type entry struct {
   cost, pos int
}

type myQueue []*entry

func (pq myQueue) Len() int {
   return len(pq)
}

func (pq myQueue) Less(i, j int) bool {
   return pq[i].cost < pq[j].cost
}

func (pq myQueue) Swap(i, j int) {
   pq[i], pq[j] = pq[j], pq[i]
}

func (pq *myQueue) Push(x interface{}) {
   item := x.(*entry)
   *pq = append(*pq, item)
}

func (pq *myQueue) Pop() interface{} {
   old := *pq
   n := len(old)
   item := old[n-1]
   *pq = old[0 : n-1]
   return item
}

func Qamount (a []byte, n int) int {
   i := 0
   for a[i] != 0 {
      i++
   }
   return i
}

func main() {
   const inf = 1e9
   myQ := &myQueue{}
   heap.Init(myQ)
   var tempTab string
   cval, oval := make([]int, 60000), make([]int, 60000)
   tab := make([]byte, 60000)
   fmt.Scanf("%v", &tempTab)
   n := len(tempTab)
   for i := 0; i < n; i++ {
      tab[i] = tempTab[i]
   }
   //fmt.Printf("%v\n", tab)
   m := Qamount(tab, n)
   for i := 0; i < m; i++ {
      fmt.Scanf("%d%d", &oval[i], &cval[i])
   }
   bal, res, pos := 0, int64(0), 0
   for i := 0; i < n; i++ {
      switch tab[i] {
      case '(':
         bal++
      case ')':
         bal--
      default:
         res += int64(cval[pos])
         tab[i] = ')'
         bal--
         heap.Push(myQ, &entry{oval[pos]-cval[pos], i})
         pos++
      }
      if bal < 0 {
         if myQ.Len() > 0 {
            temp := heap.Pop(myQ).(*entry)
            //fmt.Printf("  %v\n", heap.Pop(myQ))
            res += int64(temp.cost)
            tab[temp.pos] = '('
            bal += 2
         } else {
            bal = inf
            break
         }
      }
   }
   tempTab = string(tab)
   if bal == 0 {
      fmt.Printf("%v\n%v\n", res, tempTab)
   } else {
      fmt.Printf("-1\n")
   }
}


# coding: utf-8

"""
题解
判断一个括号序列是否合法常见的有两种方式，栈和前缀和。
使用前缀和时，初始化一个计数器为0，从左向右扫描序列，遇到左括号时计数器加一，右括号计数器减一。扫描过程中，计数器的值不能出现负数；扫描完成后，计数器的和为0，此时这个序列满足括号匹配规则。
这道题使用这种思路来做，就是一个贪心问题。
我们先将所有 ? 都当做右括号来处理。从左向右扫描序列，当计数器变为负数时，将左边的一个 ? 变为左括号，计数器加2 ，扫描完成后检查计数器是否为0。
考虑到这道题还要求替换成本最小，因此选择 ? 变为左括号时，要选择变完之后成本最小的那个。这里可以使用一个优先队列来存储 ? 替换为左右括号的成本，减少插入和获取的时间。
"""

from heapq import heappush, heappop

def solution():
    line = raw_input() # 输入的原始序列
    result = []  # 替换后的结果
    cost = 0 # 替换后的总成本
    priority_queue = [] # 优先队列
    cnt = 0 # 计数器
    for index, char in enumerate(line):
        if char == '(':
            result.append(char)
            cnt += 1
        else:
            result.append(')')
            cnt -= 1
            # 读到问号，从标准输入获取替换成本，放入优先队列
            if char == '?':
                left_cost, right_cost = map(int, raw_input().split())
                heappush(priority_queue, (left_cost - right_cost, index))
                cost += right_cost  # 问号默认先按右括号处理

            if cnt < 0:
                if not priority_queue:  # 计数器出现负数，又没有 ? 可以替换为左括号
                    break

                # 挑选从右括号变为左括号后，成本减小最大的那个问号，贪心
                tmp_cost, tmp_index = heappop(priority_queue)
                cost += tmp_cost
                result[tmp_index] = '('
                cnt += 2

    if cnt != 0:
        print -1
    else:
        print cost
        print ''.join(result)

if __name__ == '__main__':
    solution()


import heapq
e=raw_input()
c=0
k=0
l=[0]*len(e)
heap=[]
for i in xrange(len(e)):
    if e[i]=="(":
        l[i]="("
        k+=1
    elif e[i]==")":
        l[i]=")"
        k-=1

    else:
        a,b=map(int,raw_input().split())
        c+=b
        heapq.heappush(heap,(a-b,i))
        l[i]=")"
        k-=1
    #print heap
    if k<0:
        v,ind=heapq.heappop(heap)
        c+=v
        l[ind]="("
        k=1
print c
print "".join(l)


import heapq
e=raw_input()
c=0
k=0
l=[0]*len(e)
heap=[]
for i in xrange(len(e)):
    if e[i]=="(":
        l[i]="("
        k+=1
    elif e[i]==")":
        l[i]=")"
        k-=1

    else:
        a,b=map(int,raw_input().split())
        c+=b
        heapq.heappush(heap,(a-b,i))
        l[i]=")"
        k-=1

    if k<0 and heap:
          v,ind=heapq.heappop(heap)
          c+=v
          l[ind]="("
          k=1
if k!=0:
  print -1

else:

 print c
 print "".join(l)


import heapq
e=raw_input()
c=0
k=0
l=[0]*len(e)
heap=[]
for i in xrange(len(e)):
    if e[i]=="(":
        l[i]="("
        k+=1
    elif e[i]==")":
        l[i]=")"
        k-=1

    else:
        a,b=map(int,raw_input().split())
        c+=b
        heapq.heappush(heap,(a-b,i))
        l[i]=")"
        k-=1

    if k<0 and heap:
          v,ind=heapq.heappop(heap)
          c+=v
          l[ind]="("
          k+=2
if k!=0:
  print -1

else:

 print c
 print "".join(l)


import heapq
e=raw_input()
c=0
k=0
l=[0]*len(e)
heap=[]
for i in xrange(len(e)):
    if e[i]=="(":
        l[i]="("
        k+=1
    elif e[i]==")":
        l[i]=")"
        k-=1

    else:
        a,b=map(int,raw_input().split())
        c+=b
        heapq.heappush(heap,(a-b,i))
        l[i]=")"
        k-=1
    #print heap
    if k<0:
        v,ind=heapq.heappop(heap)
        c+=v
        l[ind]="("
        k=1
if k!=0:
  print -1
else:

 print c
 print "".join(l)


import heapq
e=raw_input()
c=0
k=0
l=[0]*len(e)
heap=[]
for i in xrange(len(e)):
    if e[i]=="(":
        l[i]="("
        k+=1
    elif e[i]==")":
        l[i]=")"
        k-=1

    else:
        a,b=map(int,raw_input().split())
        c+=b
        heapq.heappush(heap,(a-b,i))
        l[i]=")"
        k-=1

    if k<0 :
      if len(heap)==0:
        break
      v,ind=heapq.heappop(heap)
      c+=v
      l[ind]="("
      k+=2
if k!=0:
  print -1

else:

 print c
 print "".join(l)


import heapq
e=raw_input()
c=0
k=0
l=[0]*len(e)
heap=[]
for i in xrange(len(e)):
    if e[i]=="(":
        l[i]="("
        k+=1
    elif e[i]==")":
        l[i]=")"
        k-=1

    else:
        a,b=map(int,raw_input().split())
        c+=b
        heapq.heappush(heap,(a-b,i))
        l[i]=")"
        k-=1
    #print heap
        if k<0:
          v,ind=heapq.heappop(heap)
          c+=v
          l[ind]="("
          k=1
if k!=0:
  print -1
else:

 print c
 print "".join(l)


from heapq import heappush, heappop
from sys import stdin, exit

template = list(next(stdin).strip())

n, cost, balance = len(template), 0, 0

min_heap = []

for i in range(n):
	if template[i] == '(':
		balance += 1
	elif template[i] == ')':
		balance -= 1
	else:
		cost_left, cost_right = map(int, next(stdin).split())
		template[i] = ')'
		cost += cost_right
		balance -= 1
		heappush(min_heap, (cost_left - cost_right, i))
	if balance < 0:
		if not min_heap:
			print(-1)
			exit(0)
		change_cost, index = heappop(min_heap)
		template[index] = '('
		cost += change_cost
		balance += 2

if balance == 0:
	print(cost)
	print(''.join(template))
else:
	print(-1)


#include<bits/stdc++.h>
using namespace std;
map<string,int>mp,point;

bool cmp(string a,string b)
{   if(point[a]==point[b])
     return ((a<b));
    return point[a]>point[b];
}
int main()
{
    mp["posted"]=15,mp["likes"]=5,mp["commented"]=10;
    string a;
    cin>>a;
    int n;
    cin>>n;
    getchar();
    vector<string>vs;
    while(n--)
    {
        string s;
        vector<string>v;
        getline(cin,s);
        int x=s.size();
        for(int j=0; j<x-1; j++)
            if(s.substr(j,2)=="'s")
                s.replace(j,2,"");
        x=s.size();
        int u=0;
        for(int j=0; j<x; j++)
            if(s[j+1]==' '||j==x-1)
            {
                v.push_back(s.substr(u,j-u+1));
                u=j+2;
            }
        if(point[v[0]]==0&&v[0]!=a)
            vs.push_back(v[0]);
        if(point[v[v.size()-2]]==0&&v[v.size()-2]!=a)
            vs.push_back(v[v.size()-2]);
            if(v[0]==a)
        point[v[v.size()-2]]+=mp[v[1]];
        if(v[v.size()-2]==a)
        point[v[0]]+=mp[v[1]];
    }
    sort(vs.begin(),vs.end(),cmp);
    int x=vs.size();
    for(int i=0; i<x; i++)
        cout<<vs[i]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
map<string,int>mp,point;

bool cmp(string a,string b)
{
    if(point[a]==point[b])
        return ((a<b));
    return point[a]>point[b];
}
int main()
{
    mp["posted"]=15,mp["likes"]=5,mp["commented"]=10;
    string a;
    cin>>a;
    int n;
    cin>>n;
    getchar();
    vector<string>vs;
    while(n--)
    {
        string s;
        vector<string>v;
        getline(cin,s);
        int x=s.size();
        for(int j=0; j<x-1; j++)
            if(s.substr(j,2)=="'s")
                s.replace(j,2,"");
        x=s.size();
        int u=0;
        for(int j=0; j<x; j++)
            if(s[j+1]==' '||j==x-1)
            {
                v.push_back(s.substr(u,j-u+1));
                u=j+2;
            }
        if(point[v[0]]==0&&v[0]!=a)
            vs.push_back(v[0]);
        if(point[v[v.size()-2]]==0&&v[v.size()-2]!=a)
            vs.push_back(v[v.size()-2]);
        if(v[0]==a)
            point[v[v.size()-2]]+=mp[v[1]];
        if(v[v.size()-2]==a)
            point[v[0]]+=mp[v[1]];
    }
    set<string>st;
    sort(vs.begin(),vs.end(),cmp);
    int x=vs.size();
    for(int i=0; i<x; i++)
       st.insert(vs[i]);
       for(set<string>::iterator it=st.begin();it!=st.end();it++) cout<<*it<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
map<string,int>mp,point;

bool cmp(string a,string b)
{
    if(point[a]==point[b])
        return ((a<b));
    return point[a]>point[b];
}
int main()
{
    mp["posted"]=15,mp["likes"]=5,mp["commented"]=10;
    string a;
    cin>>a;
    int n;
    cin>>n;
    getchar();
    vector<string>vs;
    while(n--)
    {
        string s;
        vector<string>v;
        getline(cin,s);
        int x=s.size();
        for(int j=0; j<x-1; j++)
            if(s.substr(j,2)=="'s")
                s.replace(j,2,"");
        x=s.size();
        int u=0;
        for(int j=0; j<x; j++)
            if(s[j+1]==' '||j==x-1)
            {
                v.push_back(s.substr(u,j-u+1));
                u=j+2;
            }
        if(point[v[0]]==0&&v[0]!=a)
            vs.push_back(v[0]);
        if(point[v[v.size()-2]]==0&&v[v.size()-2]!=a)
            vs.push_back(v[v.size()-2]);
        if(v[0]==a)
            point[v[v.size()-2]]+=mp[v[1]];
        if(v[v.size()-2]==a)
            point[v[0]]+=mp[v[1]];
    }
    vector<string>st;
    sort(vs.begin(),vs.end(),cmp);
    int x=vs.size();
    mp.clear();
    for(int i=0; i<x; i++)
      {
          mp[vs[i]]++;
          if(mp[vs[i]]==1) st.push_back(vs[i]);
      }

    x=st.size();
    for(int i=0;i<x;i++)
        cout<<st[i]<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
map<string,int>mp,point;

bool cmp(string a,string b)
{
    return point[a]>point[b];
}
int main()
{
    mp["posted"]=15,mp["likes"]=5,mp["commented"]=10;
    string a;
    cin>>a;
    int n;
    cin>>n;
    getchar();
    vector<string>vs;
    while(n--)
    {
        string s;
        vector<string>v;
        getline(cin,s);
        int x=s.size();
        for(int j=0; j<x-1; j++)
            if(s.substr(j,2)=="'s")
                s.replace(j,2,"");
        x=s.size();
        int u=0;
        for(int j=0; j<x; j++)
            if(s[j+1]==' '||j==x-1)
            {
                v.push_back(s.substr(u,j-u+1));
                u=j+2;
            }
        if(point[v[0]]==0&&v[0]!=a)
            vs.push_back(v[0]);
        if(point[v[v.size()-2]]==0&&v[v.size()-2]!=a)
            vs.push_back(v[v.size()-2]);
        point[v[v.size()-2]]+=mp[v[1]];
        point[v[0]]+=mp[v[1]];
    }
    sort(vs.begin(),vs.end(),cmp);
    int x=vs.size();
    for(int i=0; i<x; i++)
        cout<<vs[i]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
map<string,int>mp,point;

bool cmp(string a,string b)
{   if(point[a]==point[b])
     return a<b;
    return point[a]>point[b];
}
int main()
{
    mp["posted"]=15,mp["likes"]=5,mp["commented"]=10;
    string a;
    cin>>a;
    int n;
    cin>>n;
    getchar();
    vector<string>vs;
    while(n--)
    {
        string s;
        vector<string>v;
        getline(cin,s);
        int x=s.size();
        for(int j=0; j<x-1; j++)
            if(s.substr(j,2)=="'s")
                s.replace(j,2,"");
        x=s.size();
        int u=0;
        for(int j=0; j<x; j++)
            if(s[j+1]==' '||j==x-1)
            {
                v.push_back(s.substr(u,j-u+1));
                u=j+2;
            }
        if(point[v[0]]==0&&v[0]!=a)
            vs.push_back(v[0]);
        if(point[v[v.size()-2]]==0&&v[v.size()-2]!=a)
            vs.push_back(v[v.size()-2]);
        point[v[v.size()-2]]+=mp[v[1]];
        point[v[0]]+=mp[v[1]];
    }
    sort(vs.begin(),vs.end(),cmp);
    int x=vs.size();
    for(int i=0; i<x; i++)
        cout<<vs[i]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
map<string,int>mp,point;

bool cmp(string a,string b)
{   if(point[a]==point[b])
     return ((a<b)||(b.find(a)==0));
    return point[a]>point[b];
}
int main()
{
    mp["posted"]=15,mp["likes"]=5,mp["commented"]=10;
    string a;
    cin>>a;
    int n;
    cin>>n;
    getchar();
    vector<string>vs;
    while(n--)
    {
        string s;
        vector<string>v;
        getline(cin,s);
        int x=s.size();
        for(int j=0; j<x-1; j++)
            if(s.substr(j,2)=="'s")
                s.replace(j,2,"");
        x=s.size();
        int u=0;
        for(int j=0; j<x; j++)
            if(s[j+1]==' '||j==x-1)
            {
                v.push_back(s.substr(u,j-u+1));
                u=j+2;
            }
        if(point[v[0]]==0&&v[0]!=a)
            vs.push_back(v[0]);
        if(point[v[v.size()-2]]==0&&v[v.size()-2]!=a)
            vs.push_back(v[v.size()-2]);
        point[v[v.size()-2]]+=mp[v[1]];
        point[v[0]]+=mp[v[1]];
    }
    sort(vs.begin(),vs.end(),cmp);
    int x=vs.size();
    for(int i=0; i<x; i++)
        cout<<vs[i]<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

/*

    ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥
    ♥                               ♥
    ♥   Yarab awsl wa ary7k ya omy  ♥
    ♥                               ♥
    ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥

*/

#define ll long long
#define mk make_pair

void PLAY()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

bool cmp(pair<string, ll> &a, pair<string, ll> &b)
{
    if (a.second == b.second)
    {
        return a.first < a.first;
    }
    return a.second > b.second;
}

int main()
{
    string name;
    cin >> name;
    ll n;
    cin >> n;
    map<string, ll> h;
    set<string> s;
    for (int i = 0; i < n; i++)
    {
        string a, b, c, d;
        cin >> a >> b >> c >> d;
        if (b != "likes")
        {
            c = d;
            cin >> d;
        }

        c.pop_back();
        c.pop_back();

        if (b == "posted")
        {
            if (a != name)
            {
                if (a != name)
                    s.insert(a);
                if (c == name)
                    h[a] += 15;
            }
            if (c != name)
            {
                if (c != name)
                    s.insert(c);
                if (a == name)
                    h[c] += 15;
            }
        }
        else if (b == "commented")
        {
            if (a != name)
            {
                if (a != name)
                    s.insert(a);
                if (c == name)
                    h[a] += 10;
            }
            if (c != name)
            {
                if (c != name)
                    s.insert(c);
                if (a == name)
                    h[c] += 10;
            }
        }
        else
        {
            if (a != name)
            {
                if (a != name)
                    s.insert(a);
                if (c == name)
                    h[a] += 5;
            }
            if (c != name)
            {
                if (c != name)
                    s.insert(c);
                if (a == name)
                    h[c] += 5;
            }
        }
    }

    vector<pair<string, ll>> ans;
    for (auto it = s.begin(); it != s.end(); it++)
    {
        ans.push_back({*it, h[*it]});
    }

    sort(ans.begin(), ans.end(), cmp);

    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[i].first << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

/*

    ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥
    ♥                               ♥
    ♥   Yarab awsl wa ary7k ya omy  ♥
    ♥                               ♥
    ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥

*/

#define ll long long
#define mk make_pair

void PLAY()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

bool cmp(pair<string, ll> &a, pair<string, ll> &b)
{
    if (a.second == b.second)
    {
        return a.first < a.first;
    }
    return a.second > b.second;
}

int main()
{
    string name;
    cin >> name;
    ll n;
    cin >> n;
    map<string, ll> h, m;
    m["posted"] = 15;
    m["commented"] = 10;
    m["likes"] = 5;
    set<string> s;
    for (int i = 0; i < n; i++)
    {
        string a, b, c, d;
        cin >> a >> b >> c >> d;
        if (b != "likes")
        {
            c = d;
            cin >> d;
        }

        c.pop_back();
        c.pop_back();

        if(a!=name && c==name)
        {
            h[a] += m[b];
        }

        if(a!=name)
            s.insert(a);
        if(c!=name)
            s.insert(c);
        if(a==name && c!=name)
        {
            h[c] += m[b];
            s.insert(c);
        }
    }

    vector<pair<string, ll>> ans;
    for (auto it = s.begin(); it != s.end(); it++)
    {
        ans.push_back({*it, h[*it]});
    }

    sort(ans.begin(), ans.end(), cmp);

    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[i].first << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

/*

    ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥
    ♥                               ♥
    ♥   Yarab awsl wa ary7k ya omy  ♥
    ♥                               ♥
    ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥

*/

#define ll long long
#define mk make_pair

void PLAY()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

bool cmp(pair<string,ll>&a, pair<string,ll>&b)
{
	if(a.second==b.second)
	{
		return a.first<a.first;
	}
	return a.second>b.second;
}

int main()
{
	string name;
	cin >> name;
	ll n;
	cin >> n;
	map<string, ll> h;
	set<string>s;
	for (int i = 0; i < n; i++)
	{
		string a, b, c, d;
		cin>>a>>b>>c>>d;
		if(b!="likes")
		{
			c = d;
			cin>>d;
		}

		c.pop_back();
		c.pop_back();

		if(b=="posted")
		{
			if(a!=name)
			{
				if(a!=name)
					s.insert(a);
				if(c==name)
					h[a]+=15;
			}
			if(c!=name)
			{
				if(c!=name)
					s.insert(c);
				if(a==name)
					h[c]+=15;
			}
		}
		else if(a=="commented")
		{
			if(a!=name)
			{
				if(a!=name)
					s.insert(a);
				if(c==name)
					h[a]+=10;
			}
			if(c!=name)
			{
				if(c!=name)
					s.insert(c);
				if(a==name)
					h[c]+=10;
			}
		}
		else
		{
			if(a!=name)
			{
				if(a!=name)
					s.insert(a);
				if(c==name)
					h[a]+=5;
			}
			if(c!=name)
			{
				if(c!=name)
					s.insert(c);
				if(a==name)
					h[c]+=5;
			}
		}
	}

	vector<pair<string, ll>>ans;
	for(auto it = s.begin(); it!=s.end();it++)
	{
		ans.push_back({*it, h[*it]});
	}

	sort(ans.begin(), ans.end(), cmp);

	for(int i=0;i<ans.size();i++)
	{
		cout<<ans[i].first<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

/*

    ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥
    ♥                               ♥
    ♥   Yarab awsl wa ary7k ya omy  ♥
    ♥                               ♥
    ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥

*/

#define ll long long
#define mk make_pair

void PLAY()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

bool cmp(pair<string, ll> &a, pair<string, ll> &b)
{
    if (a.second == b.second)
    {
        return a.first < a.first;
    }
    return a.second > b.second;
}

int main()
{
    string name;
    cin >> name;
    ll n;
    cin >> n;
    map<string, ll> h, m;
    m["posted"] = 15;
    m["commented"] = 10;
    m["likes"] = 5;
    set<string> s;
    for (int i = 0; i < n; i++)
    {
        string a, b, c, d;
        cin >> a >> b >> c >> d;
        if (b != "likes")
        {
            c = d;
            cin >> d;
        }

        c.pop_back();
        c.pop_back();

        if(c==name)
        {
            h[a] += m[b];
        }

        if(a!=name)
            s.insert(a);
        if(c!=name)
            s.insert(c);

        if(a==name)
        {
            h[c] += m[b];
        }
    }

    vector<pair<string, ll>> ans;
    for (auto it = s.begin(); it != s.end(); it++)
    {
        ans.push_back({*it, h[*it]});
    }

    sort(ans.begin(), ans.end(), cmp);

    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[i].first << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

/*

    ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥
    ♥                               ♥
    ♥   Yarab awsl wa ary7k ya omy  ♥
    ♥                               ♥
    ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥

*/

#define ll long long
#define mk make_pair

void PLAY()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

/*bool cmp(pair<string, ll> &a, pair<string, ll> &b)
{
    if (a.first == b.first)
    {
        return a.second < a.second;
    }
    return a.first > b.first;
}*/

int main()
{
    string name;
    cin >> name;
    ll n;
    cin >> n;
    map<string, ll> h, m;
    m["posted"] = 15;
    m["commented"] = 10;
    m["likes"] = 5;
    set<string> s;
    for (int i = 0; i < n; i++)
    {
        string a, b, c, d;
        cin >> a >> b >> c >> d;
        if (b != "likes")
        {
            c = d;
            cin >> d;
        }

        c.pop_back();
        c.pop_back();

        h[a];
        h[c];
        if (c == name)
        {
            h[a] += m[b];
        }

        if (a == name)
        {
            h[c] += m[b];
        }
    }

    vector<pair<ll, string>> ans;
    for (auto p : h)
    {
        ans.emplace_back(-p.second, p.first);
    }

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

    for (auto p : ans)
    {
        if (p.second != name)
            cout << p.second << endl;
    }

    return 0;
}


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

#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007

bool cmp(pair<int,string> i1, pair<int,string> i2)
{
    if(i1.first != i2.first)
        return (i1.first < i2.first);
    else
        return (i1.second < i2.second);
}

int main()
{
    FIO;
    int n,i,j;
    string temp;

    cin >> temp;
    cin >> n;

    temp+="'s";

    map <string,int> m;
    map <string,int> :: iterator it;

    for(j=0;j<n;j++){
        string a1,n2,tmp;

        cin >> a1 >> tmp;

        a1+="'s";

        if(tmp[0]=='p')
        {
            cin >> tmp >> n2 >> tmp;

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-15;
            else
                it->second+=-15;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-15;
            else
                it->second+=-15;

        }else if(tmp[0]=='c'){

            cin >> tmp >> n2 >> tmp;

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-10;
            else
                it->second+=-10;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-10;
            else
                it->second+=-10;

        }else{
            cin >> n2 >> tmp;

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-5;
            else
                it->second+=-5;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-5;
            else
                it->second+=-5;

        }

    }

    std::vector<pair<int, string>> v ;

    for(it=m.begin();it!=m.end();it++){
        v.push_back(make_pair(it-> second,it->first));
    }

    sort(v.begin(),v.end(),cmp);

    for(i=0;i<v.size();i++){
        if(v[i].second!=temp){
            j=0;
            while((v[i].second)[j]!=(char)39){
                cout << (v[i].second)[j];
                j++;
            }
            cout << endl;
        }
    }

	return 0;
}


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

#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007

bool cmp(pair<int,string> i1, pair<int,string> i2)
{
    if(i1.first != i2.first)
        return (i1.first < i2.first);
    else
        return (i1.second < i2.second);
}

int main()
{
    FIO;
    int n,i,j;
    string temp;

    cin >> temp;
    cin >> n;

    temp+="'s";

    map <string,int> m;
    map <string,int> :: iterator it;

    for(j=0;j<n;j++){
        string a1,n2,tmp;

        cin >> a1 >> tmp;

        a1+="'s";

        if(tmp=="posted")
        {
            cin >> tmp >> n2 >> tmp;

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-15;
            else
                it->second+=-15;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-15;
            else
                it->second+=-15;

        }else if(tmp=="commented"){

            cin >> tmp >> n2 >> tmp;

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-10;
            else
                it->second+=-10;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-10;
            else
                it->second+=-10;

        }else{
            cin >> n2 >> tmp;

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-5;
            else
                it->second+=-5;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-5;
            else
                it->second+=-5;

        }

    }

    std::vector<pair<int, string>> v ;

    for(it=m.begin();it!=m.end();it++){
        v.push_back(make_pair(it-> second,it->first));
    }

    sort(v.begin(),v.end(),cmp);

    for(i=0;i<v.size();i++){
        if(v[i].second!=temp){
            j=0;
            while((v[i].second)[j]!=(char)39){
                cout << (v[i].second)[j];
                j++;
            }
            cout << endl;
        }
    }

	return 0;
}


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

#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007

int main()
{
    FIO;
    int n,i,j;
    string temp;

    cin >> temp;
    cin >> n;

    temp+="'s";

    map <string,int> m;
    map <string,int> :: iterator it;

    for(j=0;j<n;j++){
        string a1,n2,tmp;

        cin >> a1 >> tmp;

        a1+="'s";

        if(tmp=="posted")
        {
            cin >> tmp >> n2 >> tmp;

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-15;
            else
                it->second-=15;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-15;
            else
                it->second-=15;

        }else if(tmp=="commented"){

            cin >> tmp >> n2 >> tmp;

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-10;
            else
                it->second-=10;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-10;
            else
                it->second-=10;

        }else{
            cin >> n2 >> tmp;

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-5;
            else
                it->second-=5;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-5;
            else
                it->second-=5;

        }

    }

    std::vector<pair<int, string>> v ;

    for(it=m.begin();it!=m.end();it++){
        v.push_back(make_pair(it-> second,it->first));
    }

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

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

        if(v[i].second!=temp){
            j=0;
            while((v[i].second)[j]!=(char)39){
                cout << (v[i].second)[j];
                j++;
            }
            cout << endl;
        }
    }

	return 0;
}


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

#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007

bool cmp(pair<int,string> i1, pair<int,string> i2)
{
    if(i1.first != i2.first)
        return (i1.first < i2.first);
    else
        return (i1.second < i2.second);
}

int main()
{
    FIO;
    int n,i,j;
    string temp;

    cin >> temp;
    cin >> n;

    temp+="'s";

    map <string,int> m;
    map <string,int> :: iterator it;

    for(j=0;j<n;j++){
        string a1,n2,tmp;

        bool flag=false;

        cin >> a1 >> tmp;

        a1+="'s";

        if(a1==temp)
            flag=true;

        if(tmp[0]=='p')
        {
            cin >> tmp >> n2 >> tmp;

            if(n2==temp)
                flag=true;

            if(!flag){
                it=m.find(a1);

                if(it==m.end())
                    m[a1]=0;

                it=m.find(n2);

                if(it==m.end())
                    m[n2]=0;

                continue;
            }

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-15;
            else
                it->second+=-15;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-15;
            else
                it->second+=-15;

        }else if(tmp[0]=='c'){

            cin >> tmp >> n2 >> tmp;

            if(n2==temp)
                flag=true;

            if(!flag){
                it=m.find(a1);

                if(it==m.end())
                    m[a1]=0;

                it=m.find(n2);

                if(it==m.end())
                    m[n2]=0;

                continue;
            }

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-10;
            else
                it->second+=-10;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-10;
            else
                it->second+=-10;

        }else{
            cin >> n2 >> tmp;

            if(n2==temp)
                flag=true;

            if(!flag){
                it=m.find(a1);

                if(it==m.end())
                    m[a1]=0;

                it=m.find(n2);

                if(it==m.end())
                    m[n2]=0;

                continue;
            }

            it=m.find(a1);

            if(it==m.end())
                m[a1]=-5;
            else
                it->second+=-5;

            it=m.find(n2);

            if(it==m.end())
                m[n2]=-5;
            else
                it->second+=-5;

        }

    }

    std::vector<pair<int, string>> v ;

    for(it=m.begin();it!=m.end();it++){
        v.push_back(make_pair(it-> second,it->first));
    }

    sort(v.begin(),v.end(),cmp);

    for(i=0;i<v.size();i++){
        if(v[i].second!=temp){
            j=0;
            while((v[i].second)[j]!=(char)39){
                cout << (v[i].second)[j];
                j++;
            }
            cout << endl;
        }
    }

	return 0;
}