#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e3 + 10;
class UnionSet
{
public:
	int fa[N];
	void init()
	{
		MEM(fa, -1);
	}
	int treesize(int x)
	{
		return -fa[Find(x)];
	}
	int Find(int x)
	{
		int root = x;
		while (fa[root] >= 0) root = fa[root];
		while (x != root)
		{
			int tmp = fa[x];
			fa[x] = root;
			x = tmp;
		}
		return root;
	}
	void Union(int x, int y)
	{
		int px = Find(x);
		int py = Find(y);
		if (fa[px] > fa[py]) swap(px, py);
		int sz = fa[px] + fa[py];
		fa[py] = px;
		fa[px] = sz;
	}
} uf;
int dp[N];
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, x;
	cin >> n >> x;
	uf.init();
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (a[i] == 0) continue;
		if (uf.Find(a[i]) != uf.Find(i))
			uf.Union(a[i], i);
	}
	dp[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		if (uf.Find(i) != i) continue;
		if (uf.Find(i) == uf.Find(x)) continue;
		int sz = uf.treesize(i);
		for (int j = n; j >= sz; j--)
			dp[j] |= dp[j - sz];
	}
	int cnt = 0;
	while (x)
	{
		cnt++;
		x = a[x];
	}
	for (int i = 0; i <= n; i++)
	{
		if (dp[i])
			printf("%d\n", cnt + i);
	}
	return 0;
}


#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=1e3+9;
int arr[N],dp[N],len,s,p1,s1,ok,in[MAXN];
void dfs(int nd,int flag){
	len++;
	if(nd==s)
		flag=1,ok=1;
	else if(!flag)
		s1++;
	else
		p1++;
	if(arr[nd])
		dfs(arr[nd],flag);
}
int main(){
	#ifndef ONLINE_JUDGE
    freopen("file.in", "r", stdin);
	#endif
	int n;
	scanf("%d%d",&n,&s);
	for(int i=1;i<=n;i++){
		scanf("%d",arr+i);
		in[arr[i]]=1;
	}dp[0]=1;
	int pre,suf,all=0;
	for(int i=1;i<=n;i++)
		if(!in[i]){
			len=p1=s1=ok=0;
			dfs(i,0);
			if(ok)
				pre=p1,suf=s1;
			else{
				all+=len;
				for(int j=N-len-3;j>=0;j--)
					dp[j+len]|=dp[j];
			}
		}
	for(int i=1;i<=n;i++){
		for(int j=0;j<i-pre;j++)
			if(dp[j] and all-j<=n-i-suf){
				printf("%d\n",i);
				break;
			}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300009;
// dynamic programming EKG problem // totally great!!!!!!!!!!!!
int main(){
int n,k;
cin>>n>>k;
int val[n+1];
int next[n+1];
for(int i=0;i<=n;i++)next[i]=0;
for(int i=1;i<=n;i++){
        cin>>val[i];
        next[val[i]]=i;
}
int offset=0;
vector<int> box_size;

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

    if(val[i]==0){
        bool dont_touch=false;
        int len=1;
        int st=i;
        if(i==k){
                offset=1;
                dont_touch=true;
        }

        while(next[st]!=0){
            st=next[st];
           if(st==k){
                offset=len+1;
                dont_touch=true;
        }
            len++;
        }
            if(!dont_touch)box_size.emplace_back(len);
    }
}
bool possible_pos[n+1];
memset(possible_pos,false,sizeof(possible_pos));
possible_pos[offset]=true;//our offset

for(int i=0;i<box_size.size();i++){
    for(int j=n;j>=1;j--){
        if(possible_pos[j]){
            possible_pos[j+box_size[i]]=true;
        }

    }
}
for(int i=1;i<=n;i++){
    if(possible_pos[i]){
        cout<<i<<endl;
    }
}

return 0;
}


// @author peter50216
// #includes {{{
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<functional>
#include<math.h>
#include<assert.h>
#include<stdarg.h>
#include<time.h>
#include<limits.h>
#include<ctype.h>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<iostream>
#include<sstream>
using namespace std;
// }}}
// #defines {{{
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define RI(x) scanf("%d",&x)
#define DRI(x) int x;RI(x)
#define RII(x,y) scanf("%d%d",&x,&y)
#define DRII(x,y) int x,y;RII(x,y)
#define RIII(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define DRIII(x,y,z) int x,y,z;RIII(x,y,z)
#define RS(x) scanf("%s",x)
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define CASET int ___T,cas=1;scanf("%d ",&___T);while(___T--)
#define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n)
#define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define SEP(x) ((x)?'\n':' ')
#define F first
#define S second
#ifdef ONLINE_JUDGE
#define FILEIO(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define FILEIOS freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define FILEIO(x) ;
#define FILEIOS ;
#endif
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
// }}}
int p[1010],c[1010];
int pos[1010];
int val[1010],vc;
bool dp[1010];
int main(){
    DRII(n,x);
    REP1(i,1,n){
        RI(p[i]);
        c[p[i]]=i;
    }
    REP1(i,1,n)if(p[i]==0){
        int cnt=0;
        int ii=i;
        bool f=0;
        while(ii){
            pos[ii]=cnt++;
            if(ii==x)f=1;
            ii=c[ii];
        }
        if(!f)val[vc++]=cnt;
    }
    dp[0]=1;
    int s=0;
    REP(i,vc){
        PER1(j,s,0)if(dp[j])dp[j+val[i]]=1;
        s+=val[i];
    }
    REP1(i,0,s)if(dp[i])PI(i+pos[x]+1);
}
// vim: fdm=marker:commentstring=\ \"\ %s:nowrap:autoread


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

vector<ll> v,res,vis,edge[1003];
ll n,x,ini=0,ini2=0;
bool cnt[1003][1003]={{0}},val[1003]={0};
ll dap[1003]={0},hei[1003]={0};

void DFS(int s){
	vis[s]=true;
	bool value=false;
	hei[s]=1;

	for (auto it :edge[s]) {

		if (!vis[it])	DFS(it);

		val[s]|=val[it];
		val[it]=false;

		hei[s]=hei[it]+1;
		hei[it]=0;
	}

	if (s==x) val[s]=true;
	if (s==x) ini2=hei[s];
}

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

	cin>>n>>x;
	vis.resize(n+1);

	for (ll i=0;i<n;++i) {
		ll x;
		cin>>x;
		edge[x].push_back(i+1);
	}

//	for (ll i=1;i<=n;++i){
//		cout<<i<<" :";
//		for (auto it: edge[i]) cout<<it<<" ";
//		cout<<"\n";
//	}
//	cout<<"\n";

	for (int i=1;i<=n;++i){
		if (!vis[i]){
			DFS(i);
		}
	}

//	for (int i=1;i<=n;++i) cout<<val[i]<<" ";cout<<"\n";
//	for (int i=1;i<=n;++i) cout<<hei[i]<<" ";cout<<"\n";
//	cout<<"\n";
//
	for (int i=1;i<=n;++i){
		if (val[i]) ini=hei[i];
		else v.push_back(hei[i]);
	}

//	cout<<ini<<" "<<ini2<<"\n";
//	for (auto it: v) cout<<it<<" ";
//	cout<<"\n";
//
	cnt[0][ini-ini2+1]=true;
	ll z=v.size();
	for (ll i=0;i<z;++i){
		for (ll j=1;j<=n;++j){
			cnt[i+1][j]=cnt[i][j];
			if (j>=v[i]) cnt[i+1][j]|=cnt[i][j-v[i]];
		}
	}

	for (ll i=1;i<=n;++i) if (cnt[z][i]) cout<<i<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define MOD 1000000007
#define endl '\n'

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, x;
	cin >> n >> x;
	int a[n+1];
	int notlast[n+1] = {};
	int next[n+1];
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
		notlast[ a[i] ] = 1;
		next[i] = a[i];
	}
	vector<int> qsize = {0};
	int xpos, size, p, check;
	for(int i=1; i<=n; i++)
		if( !notlast[i] )
		{
			p = i;
			size = 1;
			check = 0;
			if( i == x )
				check = xpos = 1;
			while( next[p] )
			{
				size++;
				p = next[p];
				if( p == x )
					check = xpos = size;
			}
			if( check )
				xpos = size - xpos;
			else
				qsize.pb(size);
		}
	bool sum[qsize.size()][2003] = {};
	for(int i=0; i<qsize.size(); i++)
		sum[i][0] = true;
	for(int i=1; i<qsize.size(); i++)
		for(int j=0; j < 1003; j++)
			if( sum[i-1][j] )
			{
				sum[i][ j + qsize[i] ] = true;
				sum[i][j] = true;
			}
	for(int i=0; i<1003; i++)
		if( sum[qsize.size()-1][i] )
			cout << i + xpos + 1 << endl;
	return 0;
}


//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

const int MAX_LIMIT = 1003;

int color[MAX_LIMIT], pos[MAX_LIMIT], componentSize[MAX_LIMIT];
std::vector<int> adj[MAX_LIMIT];
bool vis[MAX_LIMIT];
int currColor;
int globalColor = 1;
int nodes, nodeId;
set<int> ans;
bool done[MAX_LIMIT][MAX_LIMIT];
int before[MAX_LIMIT];

int dfs(int node, int currRank)
{
	if(vis[node])
		return 0;
	vis[node] = 1;
	color[node] = currColor;
	pos[node] = currRank;
	int i, limit = adj[node].SZ();

	if(DEBUG)
	{
		cerr << node << " " << currColor << "\n";
	}

	int ret = 0;
	fl(i,0,limit)
	{
		int v = adj[node][i];
		ret += dfs(v, currRank + 1);
	}
	return ret + 1;
}

void rec(int ind, int currSum)
{
	if(ind == globalColor)
	{
		ans.insert(currSum + pos[nodeId]);
		return;
	}

	if(done[ind][currSum])	return;
	done[ind][currSum] = 1;

	rec(ind + 1, currSum);
	if(ind != color[nodeId])
	{
		rec(ind + 1, currSum + componentSize[ind]);
	}
	return;
}

int main()
{
	int i, j;
	si(nodes);
	si(nodeId);

	fl(i,1,nodes + 1)
	{
		int x;
		si(x);
		adj[x].PB(i);
		before[i] = x;
	}

	fl(i,1,nodes + 1)
	{
		if(before[i] == 0)
		{
			currColor = globalColor;
			componentSize[globalColor] = dfs(i, 1);
			globalColor++;
		}
	}

	rec(1,0);

	set<int>::iterator itr;
	for(itr = ans.begin(); itr != ans.end(); itr++)
	{
		printf("%d\n", *itr);
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/


// next_permutation example
#include <iostream>     // std::cout
#include <algorithm>    // std::next_permutation, std::sort
#include <stdlib.h>
#include <vector>
using namespace std;

typedef long long ll;
#define fastio   std::ios_base::sync_with_stdio(false)

int main () {
  fastio;
  vector<ll> V;
  vector<ll> P;
  ll N,k,ans,i;
  cin>>N>>k;
  for(ll i=0;i<N;i++)
    V.push_back(i+1);

  do {
      ans=1;
    /*for(i=0;i<N;i++)
        cout<<V[i]<<" ";
    cout<<endl;*/
    for(i=0;i<N-1;i++)
    P.push_back(abs(V[i]-V[i+1]));
    sort(P.begin(),P.end());
    /* for(i=0;i<P.size();i++)
        cout<<P[i]<<" ";
    cout<<endl;*/
    for(i=0;i<P.size()-1;i++)
    {
        if(P[i]!=P[i+1])
            ans++;
    }
    if(ans==k)
    {
        for(i=0;i<N;i++)
            cout<<V[i]<<" ";
        cout<<endl;
        exit(0);
    }
    else
    {
        P.erase(P.begin(),P.end());
    }

  } while (next_permutation(V.begin(),V.end()));
  //cout<<"failure"<<endl;

  return 0;
}


// next_permutation example
#include <iostream>     // std::cout
#include <algorithm>    // std::next_permutation, std::sort
#include <stdlib.h>
#include <vector>
#include <string.h>
using namespace std;

typedef long long ll;
#define fastio   std::ios_base::sync_with_stdio(false)
ll P[100000]={0};
int main () {
  fastio;
  vector<ll> V;
  ll N,k,ans,i,max;
  cin>>N>>k;
  for(ll i=0;i<N;i++)
    V.push_back(i+1);

  do {
      ans=0;
      max=0;
    for(i=0;i<N-1;i++)
        {
            P[(abs(V[i]-V[i+1]))]++;
            if(max<abs(V[i]-V[i+1]))
                max=(abs(V[i]-V[i+1]));

        }
    for(i=0;i<=max;i++)
    {
        if(P[i])
            ans++;
        P[i]=0;
    }
    if(ans==k)
    {
        for(i=0;i<N;i++)
            cout<<V[i]<<" ";
        cout<<endl;
        exit(0);
    }

  } while (next_permutation(V.begin(),V.end()));
  //cout<<"failure"<<endl;

  return 0;
}


//includes
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <utility>
#include <algorithm>
#include <cassert>

using namespace std;

//typedefs
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

//defines-general
#define to(a) __typeof(a)
#define all(vec)  vec.begin(),vec.end()
#define fill(a,val)  memset(a,val,sizeof(a))

//defines-iteration
#define repi(i,a,b) for(__typeof(b) i = a;i<b;i++)
#define repii(i,a,b) for(__typeof(b) i = a;i<=b;i++)
#define repr(i,b,a) for(__typeof(b) i = b;i>a;i--)
#define repri(i,b,a) for(__typeof(b) i = b;i>=a;i--)
#define tr(vec,it)  for(__typeof(vec.begin())  it = vec.begin();it!=vec.end();++it)

//defines-pair
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

// my own
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld%lld",&a,&b)
#define slll(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sllll(a,b,c,d) scanf("%lld%lld%lld%lld",&a,&b,&c,&d)
#define fastio   std::ios_base::sync_with_stdio(false)

void generateSequence(int n,vector<int> &perm)
{
    int ctr=1;
    for(int i=0;i<n;i+=2)
        perm[i]=ctr++;

    ctr=n;
    for(int i=1;i<n;i+=2)
        perm[i]=ctr--;
}

void printPerm(int n,vector<int> &perm)
{
    int i;
    for(i=0;i<n;i++)
        cout<<perm[i]<<" ";
}

bool myFunc(int i,int j)
{
    return i>j;
}

int main()
{
    int n,k,idx,val,temp;
    cin>>n>>k;
    vector<int> perm(n);
    generateSequence(n,perm);
    if(k%2==0)
        sort(perm.begin()+k,perm.end(),myFunc);
    else
        sort(perm.begin()+k,perm.end());
    printPerm(n,perm);
}


//includes
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <utility>
#include <algorithm>
#include <cassert>

using namespace std;

//typedefs
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

//defines-general
#define to(a) __typeof(a)
#define all(vec)  vec.begin(),vec.end()
#define fill(a,val)  memset(a,val,sizeof(a))

//defines-iteration
#define repi(i,a,b) for(__typeof(b) i = a;i<b;i++)
#define repii(i,a,b) for(__typeof(b) i = a;i<=b;i++)
#define repr(i,b,a) for(__typeof(b) i = b;i>a;i--)
#define repri(i,b,a) for(__typeof(b) i = b;i>=a;i--)
#define tr(vec,it)  for(__typeof(vec.begin())  it = vec.begin();it!=vec.end();++it)

//defines-pair
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

// my own
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld%lld",&a,&b)
#define slll(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sllll(a,b,c,d) scanf("%lld%lld%lld%lld",&a,&b,&c,&d)
#define fastio   std::ios_base::sync_with_stdio(false)

int perm[100009];

void generateSequence(int n)
{
    int ctr=1;
    for(int i=0;i<n;i+=2)
        perm[i]=ctr++;

    ctr=n;
    for(int i=1;i<n;i+=2)
        perm[i]=ctr--;
}

void printPerm(int n)
{
    int i;
    for(i=0;i<n;i++)
        cout<<perm[i]<<" ";
}
int main()
{
    int n,k,idx,val;
    cin>>n>>k;
    generateSequence(n);
    //printPerm(n);
    idx=k;
    val=perm[idx-1];
    for(int i=idx;i<n;i++)
        perm[i]=++val;
    printPerm(n);
}


//includes
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <utility>
#include <algorithm>
#include <cassert>

using namespace std;

//typedefs
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

//defines-general
#define to(a) __typeof(a)
#define all(vec)  vec.begin(),vec.end()
#define fill(a,val)  memset(a,val,sizeof(a))

//defines-iteration
#define repi(i,a,b) for(__typeof(b) i = a;i<b;i++)
#define repii(i,a,b) for(__typeof(b) i = a;i<=b;i++)
#define repr(i,b,a) for(__typeof(b) i = b;i>a;i--)
#define repri(i,b,a) for(__typeof(b) i = b;i>=a;i--)
#define tr(vec,it)  for(__typeof(vec.begin())  it = vec.begin();it!=vec.end();++it)

//defines-pair
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

// my own
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld%lld",&a,&b)
#define slll(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sllll(a,b,c,d) scanf("%lld%lld%lld%lld",&a,&b,&c,&d)
#define fastio   std::ios_base::sync_with_stdio(false)

vector<int> perm(100009);

void generateSequence(int n)
{
    int ctr=1;
    for(int i=0;i<n;i+=2)
        perm[i]=ctr++;

    ctr=n;
    for(int i=1;i<n;i+=2)
        perm[i]=ctr--;
}

void printPerm(int n)
{
    int i;
    for(i=0;i<n;i++)
        cout<<perm[i]<<" ";
}

bool myFunc(int i,int j)
{
    return i<j;
}

int main()
{
    int n,k,idx,val;
    cin>>n>>k;
    generateSequence(n);
    //printPerm(n);
    idx=k;
    sort(perm.begin()+idx,perm.begin()+n-1);
    printPerm(n);
}


//includes
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <utility>
#include <algorithm>
#include <cassert>

using namespace std;

//typedefs
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

//defines-general
#define to(a) __typeof(a)
#define all(vec)  vec.begin(),vec.end()
#define fill(a,val)  memset(a,val,sizeof(a))

//defines-iteration
#define repi(i,a,b) for(__typeof(b) i = a;i<b;i++)
#define repii(i,a,b) for(__typeof(b) i = a;i<=b;i++)
#define repr(i,b,a) for(__typeof(b) i = b;i>a;i--)
#define repri(i,b,a) for(__typeof(b) i = b;i>=a;i--)
#define tr(vec,it)  for(__typeof(vec.begin())  it = vec.begin();it!=vec.end();++it)

//defines-pair
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

// my own
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld%lld",&a,&b)
#define slll(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sllll(a,b,c,d) scanf("%lld%lld%lld%lld",&a,&b,&c,&d)
#define fastio   std::ios_base::sync_with_stdio(false)

void generateSequence(int n,vector<int> &perm)
{
    int ctr=1;
    for(int i=0;i<n;i+=2)
        perm[i]=ctr++;

    ctr=n;
    for(int i=1;i<n;i+=2)
        perm[i]=ctr--;
}

void printPerm(int n,vector<int> &perm)
{
    int i;
    for(i=0;i<n;i++)
        cout<<perm[i]<<" ";
}

bool myFunc(int i,int j)
{
    return i>j;
}

int main()
{
    int n,k,idx,val,temp;
    cin>>n>>k;
    vector<int> perm(n);
    generateSequence(n,perm);
    if(k%2==0)
        sort(perm.begin()+k,perm.end(),myFunc);
    else
        sort(perm.begin()+idx,perm.end());
    printPerm(n,perm);
}


// next_permutation example
#include <iostream>     // std::cout
#include <algorithm>    // std::next_permutation, std::sort
#include <stdlib.h>
#include <vector>
#include <string.h>
using namespace std;

typedef long long ll;
#define fastio   std::ios_base::sync_with_stdio(false)
ll P[100000];
int main () {
  fastio;
  vector<ll> V;
  ll N,k,ans,i;
  cin>>N>>k;
  for(ll i=0;i<N;i++)
    V.push_back(i+1);

  do {
      ans=0;
      memset(P,0,sizeof(P));
    for(i=0;i<N-1;i++)
    P[(abs(V[i]-V[i+1]))]++;
    for(i=0;i<=N;i++)
    {
        if(P[i])
            ans++;
    }
    if(ans==k)
    {
        for(i=0;i<N;i++)
            cout<<V[i]<<" ";
        cout<<endl;
        exit(0);
    }

  } while (next_permutation(V.begin(),V.end()));
  //cout<<"failure"<<endl;

  return 0;
}


// next_permutation example
#include <iostream>     // std::cout
#include <algorithm>    // std::next_permutation, std::sort
#include <stdlib.h>
#include <vector>
using namespace std;

typedef long long ll;
#define fastio   std::ios_base::sync_with_stdio(false)
ll P[100000];
int main () {
  fastio;
  vector<ll> V;
  ll N,k,ans,i;
  cin>>N>>k;
  for(ll i=0;i<N;i++)
    V.push_back(i+1);

  do {
      ans=1;
    /*for(i=0;i<N;i++)
        cout<<V[i]<<" ";
    cout<<endl;*/
    for(i=0;i<N-1;i++)
    P[i]=(abs(V[i]-V[i+1]));
    sort(P,P+N-1);
    /* for(i=0;i<P.size();i++)
        cout<<P[i]<<" ";
    cout<<endl;*/
    for(i=0;i<N-2;i++)
    {
        if(P[i]!=P[i+1])
            ans++;
    }
    if(ans==k)
    {
        for(i=0;i<N;i++)
            cout<<V[i]<<" ";
        cout<<endl;
        exit(0);
    }

  } while (next_permutation(V.begin(),V.end()));
  //cout<<"failure"<<endl;

  return 0;
}


//includes
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <utility>
#include <algorithm>
#include <cassert>

using namespace std;

//typedefs
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

//defines-general
#define to(a) __typeof(a)
#define all(vec)  vec.begin(),vec.end()
#define fill(a,val)  memset(a,val,sizeof(a))

//defines-iteration
#define repi(i,a,b) for(__typeof(b) i = a;i<b;i++)
#define repii(i,a,b) for(__typeof(b) i = a;i<=b;i++)
#define repr(i,b,a) for(__typeof(b) i = b;i>a;i--)
#define repri(i,b,a) for(__typeof(b) i = b;i>=a;i--)
#define tr(vec,it)  for(__typeof(vec.begin())  it = vec.begin();it!=vec.end();++it)

//defines-pair
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

// my own
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld%lld",&a,&b)
#define slll(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sllll(a,b,c,d) scanf("%lld%lld%lld%lld",&a,&b,&c,&d)
#define fastio   std::ios_base::sync_with_stdio(false)

void generateSequence(int n,vector<int> &perm)
{
    int ctr=1;
    for(int i=0;i<n;i+=2)
        perm[i]=ctr++;

    ctr=n;
    for(int i=1;i<n;i+=2)
        perm[i]=ctr--;
}

void printPerm(int n,vector<int> &perm)
{
    int i;
    for(i=0;i<n;i++)
        cout<<perm[i]<<" ";
}

int main()
{
    int n,k,idx,val;
    cin>>n>>k;
    vector<int> perm(n);
    generateSequence(n,perm);
    //printPerm(n);
    idx=k;
    sort(perm.begin()+idx,perm.end());
    printPerm(n,perm);
}


//includes
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <utility>
#include <algorithm>
#include <cassert>

using namespace std;

//typedefs
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

//defines-general
#define to(a) __typeof(a)
#define all(vec)  vec.begin(),vec.end()
#define fill(a,val)  memset(a,val,sizeof(a))

//defines-iteration
#define repi(i,a,b) for(__typeof(b) i = a;i<b;i++)
#define repii(i,a,b) for(__typeof(b) i = a;i<=b;i++)
#define repr(i,b,a) for(__typeof(b) i = b;i>a;i--)
#define repri(i,b,a) for(__typeof(b) i = b;i>=a;i--)
#define tr(vec,it)  for(__typeof(vec.begin())  it = vec.begin();it!=vec.end();++it)

//defines-pair
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

// my own
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld%lld",&a,&b)
#define slll(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sllll(a,b,c,d) scanf("%lld%lld%lld%lld",&a,&b,&c,&d)
#define fastio   std::ios_base::sync_with_stdio(false)

void generateSequence(int n,vector<int> &perm)
{
    int ctr=1;
    for(int i=0;i<n;i+=2)
        perm[i]=ctr++;

    ctr=n;
    for(int i=1;i<n;i+=2)
        perm[i]=ctr--;
}

void printPerm(int n,vector<int> &perm)
{
    int i;
    for(i=0;i<n;i++)
        cout<<perm[i]<<" ";
}

int getIdx(int k,vector<int> &perm)
{
    int val,n=perm.size(),idx;
    val=perm[k-1];
    for(int i=k;i<n;i++)
    {
        if(abs(val-perm[i])==1)
            idx=i;
    }
    return idx;
}

bool myFunc(int i,int j)
{
    if(abs(i-j)==1)
        return true;
    else
        return false;
}
int main()
{
    int n,k,idx,val,temp;
    cin>>n>>k;
    vector<int> perm(n);
    generateSequence(n,perm);
    idx=getIdx(k,perm);
    temp=perm[k];
    perm[k]=perm[idx];
    perm[idx]=temp;
    sort(perm.begin()+idx,perm.end(),myFunc);
    printPerm(n,perm);
}


#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main() {
	int n,k,pairCount;
	int check[100001];
	cin.sync_with_stdio(0);
	cin  >> n >> k;
	int A[n];
	for (int i = 0; i <n;i++){
		A[i] = i+1;
	}
	do {
		memset(check, 0, sizeof check);
		pairCount =0;
		for (int i = 0; i < n-1; i++){
			if (!check[abs(A[i]-A[i+1])]){
				check[abs(A[i] - A[i+1])]=1;
				pairCount++;
				if (pairCount > k)
					break;
			}
		}
		if (pairCount == k) break;
	}while(next_permutation(A, A+n));
	for (int i = 0; i < n; i++){
		cout << A[i];
		if (i!=n-1) cout <<" ";
	}
	cout <<endl;
}


#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

void shiftRight(int l, int r, int* A) {
	int temp = A[r];
	for (int i = r; i >= l+1; i--){
		A[i] = A[i-1];
	}
	A[l] = temp;
}

int main() {
	int n,k,pairCount;
	int check[100001];
	cin.sync_with_stdio(0);
	cin  >> n >> k;
	int i;
	int start = 1;
	for (i = 0; i <= k; i++){
		if (i%2 == 0){
			cout << start++ <<" ";
		} else {
			cout << start+k-i<< " ";
		}
	}
	for (; i < n; i++){
		cout << i+1;
		if (i!= n-1) cout << " ";
	}
	cout <<endl;
}


#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main() {
	int n,k,pairCount;
	int check[100001];
	cin.sync_with_stdio(0);
	cin  >> n >> k;
	int A[n];
	for (int i = 0; i <n;i++){
		A[i] = i+1;
	}
	do {
		memset(check, 0, sizeof check);
		pairCount =0;
		for (int i = 0; i < n-1; i++){
			if (!check[abs(A[i]-A[i+1])]){
				check[abs(A[i] - A[i+1])]=1;
				pairCount++;
				if (pairCount > k)
					break;
			}
		}
		if (pairCount == k) break;
	}while(next_permutation(A, A+k+1));
	for (int i = 0; i < n; i++){
		cout << A[i];
		if (i!=n-1) cout <<" ";
	}
	cout <<endl;
}


#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

void shiftRight(int l, int r, int* A) {
	int temp = A[r];
	for (int i = l+1; i <= r; i++){
		A[i] = A[i-1];
	}
	A[l] = temp;
}

int main() {
	int n,k,pairCount;
	int check[100001];
	cin.sync_with_stdio(0);
	cin  >> n >> k;
	int A[n];
	for (int i = 0; i <n;i++){
		A[i] = i+1;
	}
	int cnt = 0;
	int pivot = 0;
	while(k){
		if (cnt %2 == 0)
			shiftRight(pivot+1,pivot + k,A);
		pivot++;
		cnt++;
		k--;
	}

	for (int i = 0; i < n; i++){
		cout << A[i];
		if (i!=n-1) cout <<" ";
	}
	cout <<endl;
}


#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

void shiftRight(int l, int r, int* A) {
	int temp = A[r];
	for (int i = r; i >= l+1; i--){
		A[i] = A[i-1];
	}
	A[l] = temp;
}

int main() {
	int n,k,pairCount;
	int check[100001];
	cin.sync_with_stdio(0);
	cin  >> n >> k;
	int A[n];
	for (int i = 0; i <n;i++){
		A[i] = i+1;
	}
	int cnt = 0;
	int pivot = 0;
	while(k){
		if (cnt %2 == 0)
			shiftRight(pivot+1,pivot + k,A);
		pivot++;
		cnt++;
		k--;
	}

	for (int i = 0; i < n; i++){
		cout << A[i];
		if (i!=n-1) cout <<" ";
	}
	cout <<endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <vector <int> > vvi;
// Input macros
#define s_(n)                        scanf("%d",&n)
#define sc_(n)                       scanf("%c",&n)
#define ss_(n)                       scanf("%s",n)
#define p_                           printf
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
#define LINF                        (LL)(1e18)
#define LEPS                        (LD)(1e-18)
#define PI                          (double)(3.141592653589793238)

// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define rep_(i,a,b)                 for(int i=a;i<b;i++)
#define rev_(i,a,b)                 for(int i=a-1;i>=b;i--)
#define repi(i,a)                   for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a)                   for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define trv(v, c)                   for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ((b).find(a) != (b).end())
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define fi                          first
#define se                          second
#define X                           real()
#define Y                           imag()

// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())

//Map and Pair printing
template <typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
{
    return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
{
    bool first = true;
    os << "[";
    for(unsigned int i = 0; i < v.size(); i++)
    {
        if(!first)
        os << ", ";
        os << v[i];
        first = false;
    }
    return os << "]";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
{
    bool first = true;
    os << "[";
    for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)
        os << ", ";
        os << *ii;
        first = false;
    }
    return os << "]";
}
template<typename T1, typename T2> inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
{
    bool first = true;
    os << "[";
    for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)os << ", ";
        os << *ii ;
        first = false;
    }
    return os << "]";
}

template <typename T> string ToString ( T Number )
  {
     ostringstream ss;
     ss << Number;
     return ss.str();
  }

int p[100005];
int main()
{
    int n,k;
    cin>>n>>k;
    p[i]=1;
    for(int i=2;i<=k+1;i++)
    {
        if(i%2==0)p[i]=p[i-1]+k-i+2;
        else p[i]=p[i-1]-(k-i+2);
    }
    for(int i=k+2;i<=n;i++)p[i]=i;
    for(int i=1;i<=n;i++)
    {
        cout<<abs(p[i])<<" ";
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <vector <int> > vvi;
// Input macros
#define s_(n)                        scanf("%d",&n)
#define sc_(n)                       scanf("%c",&n)
#define ss_(n)                       scanf("%s",n)
#define p_                           printf
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
#define LINF                        (LL)(1e18)
#define LEPS                        (LD)(1e-18)
#define PI                          (double)(3.141592653589793238)

// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define rep_(i,a,b)                 for(int i=a;i<b;i++)
#define rev_(i,a,b)                 for(int i=a-1;i>=b;i--)
#define repi(i,a)                   for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a)                   for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define trv(v, c)                   for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ((b).find(a) != (b).end())
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define fi                          first
#define se                          second
#define X                           real()
#define Y                           imag()

// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())

//Map and Pair printing
template <typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
{
    return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
{
    bool first = true;
    os << "[";
    for(unsigned int i = 0; i < v.size(); i++)
    {
        if(!first)
        os << ", ";
        os << v[i];
        first = false;
    }
    return os << "]";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
{
    bool first = true;
    os << "[";
    for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)
        os << ", ";
        os << *ii;
        first = false;
    }
    return os << "]";
}
template<typename T1, typename T2> inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
{
    bool first = true;
    os << "[";
    for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)os << ", ";
        os << *ii ;
        first = false;
    }
    return os << "]";
}

template <typename T> string ToString ( T Number )
  {
     ostringstream ss;
     ss << Number;
     return ss.str();
  }

int p[100005];
int main()
{
    int n,k;
    cin>>n>>k;
    p[0]=1;
    for(int i=2;i<=k+1;i++)
    {
        if(i%2==0)p[i]=p[i-1]+k-i+2;
        else p[i]=p[i-1]-(k-i+2);
    }
    for(int i=k+2;i<=n;i++)p[i]=i;
    for(int i=1;i<=n;i++)
    {
        cout<<abs(p[i])<<" ";
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <vector <int> > vvi;
// Input macros
#define s_(n)                        scanf("%d",&n)
#define sc_(n)                       scanf("%c",&n)
#define ss_(n)                       scanf("%s",n)
#define p_                           printf
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
#define LINF                        (LL)(1e18)
#define LEPS                        (LD)(1e-18)
#define PI                          (double)(3.141592653589793238)

// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define rep_(i,a,b)                 for(int i=a;i<b;i++)
#define rev_(i,a,b)                 for(int i=a-1;i>=b;i--)
#define repi(i,a)                   for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a)                   for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define trv(v, c)                   for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ((b).find(a) != (b).end())
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define fi                          first
#define se                          second
#define X                           real()
#define Y                           imag()

// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())

//Map and Pair printing
template <typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
{
    return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
{
    bool first = true;
    os << "[";
    for(unsigned int i = 0; i < v.size(); i++)
    {
        if(!first)
        os << ", ";
        os << v[i];
        first = false;
    }
    return os << "]";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
{
    bool first = true;
    os << "[";
    for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)
        os << ", ";
        os << *ii;
        first = false;
    }
    return os << "]";
}
template<typename T1, typename T2> inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
{
    bool first = true;
    os << "[";
    for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)os << ", ";
        os << *ii ;
        first = false;
    }
    return os << "]";
}

template <typename T> string ToString ( T Number )
  {
     ostringstream ss;
     ss << Number;
     return ss.str();
  }

int p[100005];
int main()
{
    int n,k;
    cin>>n>>k;
    p[1]=1;
    for(int i=2;i<=k+1;i++)
    {
        if(i%2==0)p[i]=p[i-1]+k-i+2;
        else p[i]=p[i-1]-(k-i+2);
    }
    for(int i=k+2;i<=n;i++)p[i]=i;
    for(int i=1;i<=n;i++)
    {
        cout<<abs(p[i])<<" ";
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <vector <int> > vvi;
// Input macros
#define s_(n)                        scanf("%d",&n)
#define sc_(n)                       scanf("%c",&n)
#define ss_(n)                       scanf("%s",n)
#define p_                           printf
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
#define LINF                        (LL)(1e18)
#define LEPS                        (LD)(1e-18)
#define PI                          (double)(3.141592653589793238)

// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define rep_(i,a,b)                 for(int i=a;i<b;i++)
#define rev_(i,a,b)                 for(int i=a-1;i>=b;i--)
#define repi(i,a)                   for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a)                   for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define trv(v, c)                   for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ((b).find(a) != (b).end())
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define fi                          first
#define se                          second
#define X                           real()
#define Y                           imag()

// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())

//Map and Pair printing
template <typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
{
    return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
{
    bool first = true;
    os << "[";
    for(unsigned int i = 0; i < v.size(); i++)
    {
        if(!first)
        os << ", ";
        os << v[i];
        first = false;
    }
    return os << "]";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
{
    bool first = true;
    os << "[";
    for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)
        os << ", ";
        os << *ii;
        first = false;
    }
    return os << "]";
}
template<typename T1, typename T2> inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
{
    bool first = true;
    os << "[";
    for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)os << ", ";
        os << *ii ;
        first = false;
    }
    return os << "]";
}

template <typename T> string ToString ( T Number )
  {
     ostringstream ss;
     ss << Number;
     return ss.str();
  }

int p[100005];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k+1;i++)
    {
        if(i%2==0)p[i]=p[i-1]+k-i+2;
        else p[i]=p[i-1]-(k-i+2);
    }
    for(int i=k+2;i<=n;i++)p[i]=i;
    for(int i=1;i<=n;i++)cout<<-1*p[i]<<" ";
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <vector <int> > vvi;
// Input macros
#define s_(n)                        scanf("%d",&n)
#define sc_(n)                       scanf("%c",&n)
#define ss_(n)                       scanf("%s",n)
#define p_                           printf
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
#define LINF                        (LL)(1e18)
#define LEPS                        (LD)(1e-18)
#define PI                          (double)(3.141592653589793238)

// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define rep_(i,a,b)                 for(int i=a;i<b;i++)
#define rev_(i,a,b)                 for(int i=a-1;i>=b;i--)
#define repi(i,a)                   for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a)                   for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define trv(v, c)                   for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ((b).find(a) != (b).end())
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define fi                          first
#define se                          second
#define X                           real()
#define Y                           imag()

// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())

//Map and Pair printing
template <typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
{
    return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
{
    bool first = true;
    os << "[";
    for(unsigned int i = 0; i < v.size(); i++)
    {
        if(!first)
        os << ", ";
        os << v[i];
        first = false;
    }
    return os << "]";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
{
    bool first = true;
    os << "[";
    for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)
        os << ", ";
        os << *ii;
        first = false;
    }
    return os << "]";
}
template<typename T1, typename T2> inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
{
    bool first = true;
    os << "[";
    for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)os << ", ";
        os << *ii ;
        first = false;
    }
    return os << "]";
}

template <typename T> string ToString ( T Number )
  {
     ostringstream ss;
     ss << Number;
     return ss.str();
  }

int p[100005];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k+1;i++)
    {
        if(i%2==0)p[i]=p[i-1]+k-i+2;
        else p[i]=p[i-1]-(k-i+2);
    }
    for(int i=k+2;i<=n;i++)p[i]=i;
    for(int i=1;i<=n;i++)cout<<p[i]<<" ";
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <vector <int> > vvi;
// Input macros
#define s_(n)                        scanf("%d",&n)
#define sc_(n)                       scanf("%c",&n)
#define ss_(n)                       scanf("%s",n)
#define p_                           printf
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
#define LINF                        (LL)(1e18)
#define LEPS                        (LD)(1e-18)
#define PI                          (double)(3.141592653589793238)

// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define rep_(i,a,b)                 for(int i=a;i<b;i++)
#define rev_(i,a,b)                 for(int i=a-1;i>=b;i--)
#define repi(i,a)                   for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a)                   for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define trv(v, c)                   for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ((b).find(a) != (b).end())
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define fi                          first
#define se                          second
#define X                           real()
#define Y                           imag()

// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())

//Map and Pair printing
template <typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
{
    return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
{
    bool first = true;
    os << "[";
    for(unsigned int i = 0; i < v.size(); i++)
    {
        if(!first)
        os << ", ";
        os << v[i];
        first = false;
    }
    return os << "]";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
{
    bool first = true;
    os << "[";
    for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)
        os << ", ";
        os << *ii;
        first = false;
    }
    return os << "]";
}
template<typename T1, typename T2> inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
{
    bool first = true;
    os << "[";
    for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)os << ", ";
        os << *ii ;
        first = false;
    }
    return os << "]";
}

template <typename T> string ToString ( T Number )
  {
     ostringstream ss;
     ss << Number;
     return ss.str();
  }

int p[100005];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k+1;i++)
    {
        if(i%2==0)p[i]=p[i-1]+k-i+2;
        else p[i]=p[i-1]-(k-i+2);
    }
    for(int i=k+2;i<=n;i++)p[i]=i;
    for(int i=1;i<=n;i++)
    {
        cout<<abs(p[i])<<" ";
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <vector <int> > vvi;
// Input macros
#define s_(n)                        scanf("%d",&n)
#define sc_(n)                       scanf("%c",&n)
#define ss_(n)                       scanf("%s",n)
#define p_                           printf
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
#define LINF                        (LL)(1e18)
#define LEPS                        (LD)(1e-18)
#define PI                          (double)(3.141592653589793238)

// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define rep_(i,a,b)                 for(int i=a;i<b;i++)
#define rev_(i,a,b)                 for(int i=a-1;i>=b;i--)
#define repi(i,a)                   for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a)                   for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define trv(v, c)                   for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ((b).find(a) != (b).end())
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define fi                          first
#define se                          second
#define X                           real()
#define Y                           imag()

// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())

//Map and Pair printing
template <typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
{
    return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
{
    bool first = true;
    os << "[";
    for(unsigned int i = 0; i < v.size(); i++)
    {
        if(!first)
        os << ", ";
        os << v[i];
        first = false;
    }
    return os << "]";
}
template<typename T> inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
{
    bool first = true;
    os << "[";
    for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)
        os << ", ";
        os << *ii;
        first = false;
    }
    return os << "]";
}
template<typename T1, typename T2> inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
{
    bool first = true;
    os << "[";
    for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)os << ", ";
        os << *ii ;
        first = false;
    }
    return os << "]";
}

template <typename T> string ToString ( T Number )
  {
     ostringstream ss;
     ss << Number;
     return ss.str();
  }

int p[100005];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k+1;i++)
    {
        if(i%2==0)p[i]=p[i-1]+k-i+2;
        else p[i]=p[i-1]-(k-i+2);
    }
    for(int i=k+2;i<=n;i++)p[i]=i;
    for(int i=k+2;i<=n;i++)cout<<p[i]<<" ";
    return 0;
}


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

int main(int argc, char const* argv[])
{
	int n, k;
	cin >> n >> k;
	int c = 0;
	int t = 1, i = 1, j = k + 1;
	while(n > 0)
	{
		int s1 = i, s2 = j;
		while(i <= j && n--)
		{
			if(t) printf("%d", i++);
			else printf("%d", j--);
			if(n) printf(" ");
			t ^= 1;
		}
		i = s2 + 1, j = i + k, t = 1;
	}
	puts("");
	return 0;
}


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

int main(int argc, char const* argv[])
{
	int n, k;
	cin >> n >> k;
	int N = n;
	int c = 0;
	int t = 1, i = 1, j = k + 1;
	while(n > 0)
	{
		int s1 = i, s2 = j;
		while(i <= j && n--)
		{
			if(t) printf("%d", i++);
			else printf("%d", j--);
			if(n) printf(" ");
			t ^= 1;
		}
		i = s2 + 1, j = min(i + k, N), t = 1;
	}
	puts("");
	return 0;
}


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

int main(int argc, char const* argv[])
{
	int n, k;
	cin >> n >> k;
	int c = 0;
	int t = 1, i = 2, j = k;
	printf("1");
	--n;
	while(i < j && n--)
	{
		if(t) printf(" %d", j--);
		else printf(" %d", i++);
		t ^= 1;
	}
	while(n--) printf(" %d", i);
	puts("");
	return 0;
}


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

int main(int argc, char const* argv[])
{
	unsigned long long n, k;
	cin >> n >> k;
	int c = 0;
	printf("1");
	for(unsigned long long i = 1; i <= k; ++i) cout << " " << 1 + ((i * (i + 1)) >> 1);
	for(unsigned long long i = k + 1; i < n; ++i) cout << " " << 1 + i + ((k * (k - 1)) >> 1);
	puts("");
	return 0;
}


//
//  main.cpp
//  C
//
//  Created by Anton Yakimenko on 24.10.14.
//  Copyright (c) 2014 Anton Yakimenko. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <list>
#include <iterator>
#define MAX 8000002
using namespace std;
int main(int argc, const char * argv[]) {
    long n, k;
    list<int> p;
    for(int i=2; i<MAX; ++i)
        p.insert(p.end(), i);
    unsigned long long last = 1;
    cin >> n >> k;
    long oldK = k;
    cout << "1 ";
    list<int>::iterator prevIt=p.begin();
    list<int>::iterator it;
    for(unsigned long long i=1; i<n; ++i)
    {
        it = prevIt;
        while(it != p.end())
        {
            long abS = abs((long)(*it-last));
            if(abS==k || (k==1&&abS<=oldK&&abS>=1))
            {
                cout << *it << ' ';
                if(k>1)
                    --k;
                last = *it;
                prevIt = it;
                ++prevIt;
                p.erase(it);
                break;
            }
            ++it;
        }
    }
    return 0;
}


//
//  main.cpp
//  C
//
//  Created by Anton Yakimenko on 24.10.14.
//  Copyright (c) 2014 Anton Yakimenko. All rights reserved.
//

#include <iostream>
#include <cmath>
#define MAX 1000002
using namespace std;
int main(int argc, const char * argv[]) {
    long n, k;
    bool p[MAX];
    p[1] = 1;
    for(int i=2; i<MAX; ++i)
        p[i]=0;
    unsigned long long last = 1;
    cin >> n >> k;
    long oldK = k;
    unsigned long long beginIndex = 2;
    bool f;
    cout << "1 ";
    for(unsigned long long i=1; i<n; ++i)
    {
        f = 0;
        for(unsigned long long j=beginIndex; j<MAX; ++j)
        {
            long abS = abs((long)(j-last));
            if(!p[j])
            {
                if(!f)
                {
                    beginIndex = j+1;
                    f = 1;
                }
                if(abS==k || (k==1&&abS<=oldK&&abS>=1))
                {
                    cout << j << ' ';
                    if(k>1)
                        --k;
                    last = j;
                    p[j] = 1;
                    break;
                }
            }
        }
    }
    return 0;
}


//
//  main.cpp
//  C
//
//  Created by Anton Yakimenko on 24.10.14.
//  Copyright (c) 2014 Anton Yakimenko. All rights reserved.
//

#include <iostream>
#include <cmath>
#define MAX 1000002
using namespace std;
int main(int argc, const char * argv[]) {
    long n, k;
    bool p[MAX];
    p[1] = 1;
    for(int i=2; i<MAX; ++i)
        p[i]=0;
    unsigned long long last = 1;
    cin >> n >> k;
    long oldK = k;
    unsigned long long beginIndex = 2;
    bool f;
    cout << "1 ";
    for(unsigned long long i=1; i<n; ++i)
    {
        f = 0;
        for(unsigned long long j=beginIndex; j<MAX; ++j)
        {
            long abS = abs((long)(j-last));
            if(!p[j])
            {
                if(!f)
                {
                    beginIndex = j;
                    f = 1;
                }
                if(abS==k || (k==1&&abS<=oldK&&abS>=1))
                {
                    cout << j << ' ';
                    if(k>1)
                        --k;
                    last = j;
                    p[j] = 1;
                    break;
                }
            }
        }
    }
    return 0;
}


//
//  main.cpp
//  C
//
//  Created by Anton Yakimenko on 24.10.14.
//  Copyright (c) 2014 Anton Yakimenko. All rights reserved.
//

#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, const char * argv[]) {
    long n, k;
    bool p[100002];
    p[1] = 1;
    for(int i=2; i<=100001; ++i)
        p[i]=0;
    unsigned long long last = 1;
    cin >> n >> k;
    long oldK = k;
    cout << "1 ";
    for(unsigned long long i=1; i<n; ++i)
    {
        for(unsigned long long j=2; j<=100001; ++j)
        {
            long abS = abs((long)(j-last));
            if(!p[j] && (abS==k || (k==1&&abS<=oldK&&abS>=1)))
            {
                cout << j << ' ';
                if(k>1)
                    --k;
                last = j;
                p[j] = 1;
                break;
            }
        }
    }
    return 0;
}


//
//  main.cpp
//  C
//
//  Created by Anton Yakimenko on 24.10.14.
//  Copyright (c) 2014 Anton Yakimenko. All rights reserved.
//

#include <iostream>
#include <cmath>
#define MAX 100002
using namespace std;
int main(int argc, const char * argv[]) {
    long n, k;
    cin >> n >> k;
    cout << "1 ";
    long a = k+1, b=2;
    for(unsigned long long i=1; i<=k; ++i)
    {
        if(i%2)
            cout << a--<< ' ';
        else
            cout << b++ << ' ';
    }
    for(long i=k+2; i<=n; ++i)
    {
        cout << i << ' ';
    }
    return 0;
}


//
//  main.cpp
//  C
//
//  Created by Anton Yakimenko on 24.10.14.
//  Copyright (c) 2014 Anton Yakimenko. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <list>
#include <iterator>
#define MAX 100002
using namespace std;
int main(int argc, const char * argv[]) {
    long n, k;
    list<int> p;
    for(int i=2; i<MAX; ++i)
        p.insert(p.end(), i);
    unsigned long long last = 1;
    cin >> n >> k;
    long oldK = k;
    cout << "1 ";
    list<int>::iterator it;
    for(unsigned long long i=1; i<n; ++i)
    {
        it = p.begin();
        while(it != p.end())
        {
            long abS = abs((long)(*it-last));
            if(abS==k || (k==1&&abS<=oldK&&abS>=1))
            {
                cout << *it << ' ';
                if(k>1)
                    --k;
                last = *it;
                p.erase(it);
                break;
            }
            ++it;
        }
    }
    return 0;
}


//BISMILLAHIRRAHMANIRRAHIM
/*
 manus tar shopner soman boro
 Author :: Shakil Ahmed
.............AUST_CSE27.........
 prob   ::
 Type   ::
 verdict::
 */

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define ff first
#define ss second
#define re return
#define QI queue<int>
#define SI stack<int>
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define memo(a,b) memset((a),(b),sizeof(a))
#define G() getchar()
#define MAX3(a,b,c) max(a,max(b,c))

double const EPS=3e-8;
using namespace std;

#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

typedef long long Long;
typedef long long int64;
typedef unsigned long long ull;
typedef vector<int> vi ;
typedef set<int> si;
typedef vector<Long>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<Long,Long>pll;
typedef pair<double,double>pdd;
typedef vector<pii> vpii;

// For loop

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction

/* **************************************  My code start here ****************************************** */
Long n , k ;
const int MX = 1e6 + 9 ;
Long Ans[MX];
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k ;
    if ( k == 1 )
    {
        for ( int i = 0 ; i < n ; i++ )
        {
            if( i ) cout << " ";

            cout << i + 1 ;
        }
        cout<<endl;
        return 0 ;
    }
    Long low = 1 , high = k + 1 ;
    int idx = k , i , j ;
    while(1)
    {
        Ans[idx] = high ;
        high--;
        idx--;
        if( idx < 0 ) break ;
        Ans[idx] = low ;
        low++;
        idx--;
        if( idx < 0 ) break;
    }
    for ( i = k + 1 , j = k + 2 ; i < n ; i++ , j++ )
    {
        Ans[i] = j ;
    }
    for ( i = 0 ; i < n ; i++ )
    {
        if( i > 0 ) cout << " ";
        cout << Ans[i];
    }
    cout << endl ;
    return 0;
}


//BISMILLAHIRRAHMANIRRAHIM
/*
 manus tar shopner soman boro
 Author :: Shakil Ahmed
.............AUST_CSE27.........
 prob   ::
 Type   ::
 verdict::
 */

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define ff first
#define ss second
#define re return
#define QI queue<int>
#define SI stack<int>
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define memo(a,b) memset((a),(b),sizeof(a))
#define G() getchar()
#define MAX3(a,b,c) max(a,max(b,c))

double const EPS=3e-8;
using namespace std;

#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

typedef long long Long;
typedef long long int64;
typedef unsigned long long ull;
typedef vector<int> vi ;
typedef set<int> si;
typedef vector<Long>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<Long,Long>pll;
typedef pair<double,double>pdd;
typedef vector<pii> vpii;

// For loop

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction

/* **************************************  My code start here ****************************************** */
Long n , k ;
const int MX = 1e6 + 9 ;
Long Ans[MX];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k ;
    if ( k == 1 )
    {
        for ( int i = 0 ; i < n ; i++ )
        {
            if( i ) printf(" ");

            printf("%d",i+1);
        }
        cout<<endl;
        return 0 ;
    }
    Long low = 1 , high = k + 1 ;
    int idx = k , i , j ;
    while(1)
    {
        Ans[idx] = high ;
        high--;
        idx--;
        if( idx < 0 ) break ;
        Ans[idx] = low ;
        low++;
        idx--;
        if( idx < 0 ) break;
    }
    for ( i = k + 1 , j = k + 2 ; i < n ; i++ , j++ )
    {
        Ans[i] = j ;
    }
    for ( i = 0 ; i < n ; i++ )
    {
        if( i > 0 ) cout << " ";
        cout << Ans[i];
    }
    cout << endl ;
    return 0;
}


 //BISMILLAHIRRAHMANIRRAHIM
/*
 manus tar shopner soman boro
 Author :: Shakil Ahmed
.............AUST_CSE27.........
 prob   ::
 Type   ::
 verdict::
 */

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define ff first
#define ss second
#define re return
#define QI queue<int>
#define SI stack<int>
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define memo(a,b) memset((a),(b),sizeof(a))
#define G() getchar()
#define MAX3(a,b,c) max(a,max(b,c))

double const EPS=3e-8;
using namespace std;

#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

typedef long long Long;
typedef long long int64;
typedef unsigned long long ull;
typedef vector<int> vi ;
typedef set<int> si;
typedef vector<Long>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<Long,Long>pll;
typedef pair<double,double>pdd;
typedef vector<pii> vpii;

// For loop

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction

/* **************************************  My code start here ****************************************** */
Long n , k ;
const int MX = 1e6 + 9 ;
Long Ans[MX];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k ;
    if ( k == 1 )
    {
        For(i,n) cout << i << " ";
        cout<<endl;
        return 0 ;
    }
    Long low = 1 , high = k + 1 ;
    int idx = k , i , j ;
    while(i)
    {
        Ans[idx] = high ;
        high--;
        idx--;
        if( idx < 0 ) break ;
        Ans[idx] = low ;
        low++;
        idx--;
        if( idx < 0 ) break;
    }
    for ( i = k + 1 , j = k + 2 ; i < n ; i++ , j++ )
    {
        Ans[i] = j ;
    }
    for ( i = 0 ; i < n ; i++ )
    {
        cout << Ans[i]<<" ";
    }
    cout << endl ;
    return 0;
}


 //BISMILLAHIRRAHMANIRRAHIM
/*
 manus tar shopner soman boro
 Author :: Shakil Ahmed
.............AUST_CSE27.........
 prob   ::
 Type   ::
 verdict::
 */

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define ff first
#define ss second
#define re return
#define QI queue<int>
#define SI stack<int>
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define memo(a,b) memset((a),(b),sizeof(a))
#define G() getchar()
#define MAX3(a,b,c) max(a,max(b,c))

double const EPS=3e-8;
using namespace std;

#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

typedef long long Long;
typedef long long int64;
typedef unsigned long long ull;
typedef vector<int> vi ;
typedef set<int> si;
typedef vector<Long>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<Long,Long>pll;
typedef pair<double,double>pdd;
typedef vector<pii> vpii;

// For loop

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction

/* **************************************  My code start here ****************************************** */
Long n , k ;
const int MX = 1e6 + 9 ;
Long Ans[MX];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k ;
    if ( k == 1 )
    {
        for ( int i = 0 ; i < n ; i++ )
        {
            if( i ) printf(" ");

            printf("%d",i+1);
        }
        cout<<endl;
        return 0 ;
    }
    Long low = 1 , high = k + 1 ;
    int idx = k , i , j ;
    while(1)
    {
        Ans[idx] = high ;
        high--;
        idx--;
        if( idx < 0 ) break ;
        Ans[idx] = low ;
        low++;
        idx--;
        if( idx < 0 ) break;
    }
    for ( i = k + 1 , j = k + 2 ; i < n ; i++ , j++ )
    {
        Ans[i] = j ;
    }
    for ( i = 0 ; i < n ; i++ )
    {
        if( i > 0 ) cout << " ";
        cout << Ans[i];
    }
    cout << endl ;
    return 0;
}


 //BISMILLAHIRRAHMANIRRAHIM
/*
 manus tar shopner soman boro
 Author :: Shakil Ahmed
.............AUST_CSE27.........
 prob   ::
 Type   ::
 verdict::
 */

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define ff first
#define ss second
#define re return
#define QI queue<int>
#define SI stack<int>
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define memo(a,b) memset((a),(b),sizeof(a))
#define G() getchar()
#define MAX3(a,b,c) max(a,max(b,c))

double const EPS=3e-8;
using namespace std;

#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

typedef long long Long;
typedef long long int64;
typedef unsigned long long ull;
typedef vector<int> vi ;
typedef set<int> si;
typedef vector<Long>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<Long,Long>pll;
typedef pair<double,double>pdd;
typedef vector<pii> vpii;

// For loop

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction

/* **************************************  My code start here ****************************************** */
Long n , k ;
const int MX = 1e6 + 9 ;
Long Ans[MX];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k ;
    if ( k == 1 )
    {
        for ( int i = 0 ; i < n ; i++ )
        {
            if( i ) printf(" ");

            printf("%d",i+1);
        }
        cout<<endl;
        return 0 ;
    }
    Long low = 1 , high = k + 1 ;
    int idx = k , i , j ;
    while(i)
    {
        Ans[idx] = high ;
        high--;
        idx--;
        if( idx < 0 ) break ;
        Ans[idx] = low ;
        low++;
        idx--;
        if( idx < 0 ) break;
    }
    for ( i = k + 1 , j = k + 2 ; i < n ; i++ , j++ )
    {
        Ans[i] = j ;
    }
    for ( i = 0 ; i < n ; i++ )
    {
        if( i > 0 ) cout << " ";
        cout << Ans[i];
    }
    cout << endl ;
    return 0;
}


//BISMILLAHIRRAHMANIRRAHIM
/*
 manus tar shopner soman boro
 Author :: Shakil Ahmed
.............AUST_CSE27.........
 prob   ::
 Type   ::
 verdict::
 */

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define ff first
#define ss second
#define re return
#define QI queue<int>
#define SI stack<int>
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define memo(a,b) memset((a),(b),sizeof(a))
#define G() getchar()
#define MAX3(a,b,c) max(a,max(b,c))

double const EPS=3e-8;
using namespace std;

#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

typedef long long Long;
typedef long long int64;
typedef unsigned long long ull;
typedef vector<int> vi ;
typedef set<int> si;
typedef vector<Long>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<Long,Long>pll;
typedef pair<double,double>pdd;
typedef vector<pii> vpii;

// For loop

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction

/* **************************************  My code start here ****************************************** */
Long n , k ;
const int MX = 1e6 + 9 ;
Long Ans[MX];
int main()
{
   // ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k ;
    if ( k == 1 )
    {
        for ( int i = 0 ; i < n ; i++ )
        {
            if( i ) printf(" ");

            printf("%d",i+1);
        }
        cout<<endl;
        return 0 ;
    }
    Long low = 1 , high = k + 1 ;
    int idx = k , i , j ;
    while(1)
    {
        Ans[idx] = high ;
        high--;
        idx--;
        if( idx < 0 ) break ;
        Ans[idx] = low ;
        low++;
        idx--;
        if( idx < 0 ) break;
    }
    for ( i = k + 1 , j = k + 2 ; i < n ; i++ , j++ )
    {
        Ans[i] = j ;
    }
    for ( i = 0 ; i < n ; i++ )
    {
        if( i > 0 ) cout << " ";
        cout << Ans[i];
    }
    cout << endl ;
    return 0;
}


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

int main() {
    long long n,k;

    cin>>n>>k;

    if (k == 1)
        for(long long i = 1; i <=n; i++)
        {
            if(i != 1)
                cout<<" ";
            cout<<i;
        }
    else
    {
        long long i = 1;
        long long kk = k;
        bool c = false;
        if (k >= n/2)
            c = true;

        bool d = true;
        while(--kk > 0 && n > i)
        {
            if (kk != k-1)
                cout<<" ";

            if (c)
            {
                cout<<n<<" "<<i;
                kk--;
                if (k%2 == 0)
                     d = false;
                else
                    d = true;
            }
            else if (d)
            {
                cout<<n<<" "<<i;
                d = false;
            }
            else
            {
                cout<<i<<" "<<n;
                d = true;
            }

            i++;
            n--;
        }
        if (!d)
        for(long long j = i; j <= n; j++)
        {
            cout<<" "<<j;
        }
        else
        for(long long j = n; j >= i; j--)
        {
            cout<<" "<<j;
        }
    }

    return 0;
}


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

int main() {
    long long n,k;

    cin>>n>>k;

    if (k == 1)
        for(int i = 1; i <=n; i++)
        {
            if(i != 1)
                cout<<" ";
            cout<<i;
        }
    else
    {
        int i = 1;
        int kk = k;
        bool d = true;
        while(--kk)
        {
            if (kk != k-1)
                cout<<" ";
            if (d)
            {
                cout<<n<<" "<<i;
                d = false;
            }
            else
            {
                cout<<i<<" "<<n;
                d = true;
            }

            i++;
            n--;
        }
        for(int j = i; j <= n; j++)
        {
            cout<<" "<<j;
        }
    }

    return 0;
}


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

int main() {
    long long n,k;

    cin>>n>>k;

    if (k == 1)
        for(long long i = 1; i <=n; i++)
        {
            if(i != 1)
                cout<<" ";
            cout<<i;
        }
    else
    {
        long long i = 1;
        long long kk = k;
        bool c = false;
        if (k == n-1)
            c = true;

        bool d = true;
        while(--kk && n!=i)
        {
            if (kk != k-1)
                cout<<" ";
            if (d || c)
            {
                cout<<n<<" "<<i;
                d = false;
            }
            else
            {
                cout<<i<<" "<<n;
                d = true;
            }

            i++;
            n--;
        }
        if (!d)
        for(long long j = i; j <= n; j++)
        {
            cout<<" "<<j;
        }
        else
        for(long long j = n; j >= i; j--)
        {
            cout<<" "<<j;
        }
    }

    return 0;
}


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

int main() {
    long long n,k;

    cin>>n>>k;

    if (k == 1)
        for(int i = 1; i <=n; i++)
        {
            if(i != 1)
                cout<<" ";
            cout<<i;
        }
    else
    {
        int i = 1;
        while(--k)
        {
            cout<<n<<" "<<i;
            i++;
            n--;
        }
        for(int j = i; j <= n; j++)
        {
            cout<<" "<<j;
        }
    }

    return 0;
}


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

int main() {
    long long n,k;

    cin>>n>>k;

    if (k == 1)
        for(long long i = 1; i <=n; i++)
        {
            if(i != 1)
                cout<<" ";
            cout<<i;
        }
    else
    {
        long long i = 1;
        long long kk = k;
        bool c = false;
        if (k == n-1)
            c = true;

        bool d = true;
        while(--kk && n > i)
        {
            if (kk != k-1)
                cout<<" ";
            if (d || c)
            {
                cout<<n<<" "<<i;
                d = false;
            }
            else
            {
                cout<<i<<" "<<n;
                d = true;
            }

            i++;
            n--;
        }
        if (!d)
        for(long long j = i; j <= n; j++)
        {
            cout<<" "<<j;
        }
        else
        for(long long j = n; j >= i; j--)
        {
            cout<<" "<<j;
        }
    }

    return 0;
}


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

int main() {
    long long n,k;

    cin>>n>>k;

    if (k == 1)
        for(int i = 1; i <=n; i++)
        {
            if(i != 1)
                cout<<" ";
            cout<<i;
        }
    else
    {
        int i = 1;
        int kk = k;
        bool d = true;
        while(--kk)
        {
            if (kk != k-1)
                cout<<" ";
            if (d)
            {
                cout<<n<<" "<<i;
                d = false;
            }
            else
            {
                cout<<i<<" "<<n;
                d = true;
            }

            i++;
            n--;
        }
        if (!d)
        for(int j = i; j <= n; j++)
        {
            cout<<" "<<j;
        }
        else
        for(int j = n; j >= i; j--)
        {
            cout<<" "<<j;
        }
    }

    return 0;
}


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

int main() {
    long long n,k;

    cin>>n>>k;

    if (k == 1)
        for(int i = 1; i <=n; i++)
        {
            if(i != 1)
                cout<<" ";
            cout<<i;
        }
    else
    {
        int i = 1;
        while(--k)
        {
            cout<<i<<" "<<n;
            i++;
            n--;
        }
        for(int j = i; j <= n; j++)
        {
            cout<<" "<<j;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
main()
{
	cout<<3<<" "<<1<<" "<<2;
}


#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstring>
using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; i++)
    {
        a[i] = i;
    }
   // for (int i = 1; i <= n; i++)
  //  {
  //      cout << a[i] << " ";
  //  }
    //cout << endl;
    int na = 1;
    int pos = 0;
    bool flag = true;
    while (na != k)
    {
        if (flag)
        {
            swap(a[n], a[n - 1]);
            flag = false;
            na++;
        }
        else
        {
            for (int i = n - 1; i > pos + 1; i--)
                swap(a[i], a[i - 1]);
            flag = true;
            pos += 2;
            na++;
        }
    }
    if (k % 2 == 0)
    {
        for (int i = 1; i <= n; i++)
        {
            cout << a[i] << " ";
        }
    }
    else
    {
        swap(a[n], a[n - 1]);
        for (int i = 1; i <= n; i++)
        {
            cout << a[i] << " ";
        }
    }
}


#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstring>
using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    if (k > 1)
    {
        int p = n;
        int s = 1;
        bool flag = false;
        cout << p << " " << 1 << " " ;
        k -= 2;
        if (k / 2 > 0)
            flag = true;   //cout << k;
        while (k >= 0)
        {
            if (flag)
            {
                p -= 1;
                s++;
                k -= 2;
                cout << p << " " << s << " " ;
            }
            else
            {
                if (k == 0)
                {
                    for (int j = s + 1; j < n - s + 1; j++)
                        cout << j << " " ;
                    break;
                }

                else                                                //k == 1
                {
                    int j;
                    for (j = s + 1; j < n - s - 1; j++)
                        cout << j << " " ;
                    cout << j + 1 << " " << j;
                    break;
                }
            }
            if (k / 2 < 1)
                flag = false;
        }
    }
    else
        for (int i = 1; i < n + 1; i++)
            cout << i << " " ;
}


#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstring>
using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; i++)
    {
        a[i] = i;
    }
   // for (int i = 1; i <= n; i++)
  //  {
  //      cout << a[i] << " ";
  //  }
    //cout << endl;
    if (k != 1)
    {

    int na = 1;
    int pos = 0;
    bool flag = true;
    while (na <= k)
    {
        if (flag)
        {
            swap(a[n], a[n - 1]);
            flag = false;
            na++;
        }
        else
        {
            for (int i = n - 1; i > pos + 1; i--)
                swap(a[i], a[i - 1]);
            flag = true;
            pos += 2;
            na++;
        }
    }
    if (k % 2 == 0)
    {
        for (int i = n - 1; i > pos + 1; i--)
                swap(a[i], a[i - 1]);
        for (int i = 1; i <= n; i++)
        {
            cout << a[i] << " ";
        }
    }
    else
    {
        swap(a[n], a[n - 1]);
        for (int i = 1; i <= n; i++)
        {
            cout << a[i] << " ";
        }
    }
    }
    else
    {
    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << " ";
    }
    }
}


#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstring>
using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    if (k > 1)
    {
        int p = n;
        int s = 1;
        bool flag = false;
        cout << p << " " << 1 << " " ;
        k -= 2;
        if (k / 2 > 0)
            flag = true;   //cout << k;
        while (k >= 0)
        {
            if (flag)
            {
                p -= 1;
                s++;
                k -= 2;
                cout << p << " " << s << " " ;
            }
            else
            {
                if (k == 0)
                {
                    for (int j = s + 1; j < n - s + 1; j++)
                        cout << j << " " ;
                    break;
                }

                else                                                //k == 1
                {
                    int j;
                    for (j = s + 1; j < n - s - 1; j++)
                        cout << j << " " ;
                    cout << j + 2 << " " << j + 1;
                    break;
                }
            }
            if (k / 2 < 1)
                flag = false;
        }
    }
    else
        for (int i = 1; i < n + 1; i++)
            cout << i << " " ;
}


#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstring>
using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; i++)
    {
        a[i] = i;
    }
   // for (int i = 1; i <= n; i++)
  //  {
  //      cout << a[i] << " ";
  //  }
    //cout << endl;
    if (k != 1)
    {

    int na = 1;
    int pos = 0;
    bool flag = true;
    while (na != k)
    {
        if (flag)
        {
            swap(a[n], a[n - 1]);
            flag = false;
            na++;
        }
        else
        {
            for (int i = n - 1; i > pos + 1; i--)
                swap(a[i], a[i - 1]);
            flag = true;
            pos += 2;
            na++;
        }
    }
    if (k % 2 == 0)
    {
        for (int i = 1; i <= n; i++)
        {
            cout << a[i] << " ";
        }
    }
    else
    {
        swap(a[n], a[n - 1]);
        for (int i = 1; i <= n; i++)
        {
            cout << a[i] << " ";
        }
    }
    }
    else
    {
    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << " ";
    }
    }
}


#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstring>
using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; i++)
    {
        a[i] = i;
    }
   // for (int i = 1; i <= n; i++)
  //  {
  //      cout << a[i] << " ";
  //  }
    //cout << endl;
    if (k != 1)
    {

    int na = 1;
    int pos = 0;
    bool flag = true;
    while (na != k)
    {
        if (flag)
        {
            swap(a[n], a[n - 1]);
            flag = false;
            na++;
        }
        else
        {
            for (int i = n - 1; i > pos + 1; i--)
                swap(a[i], a[i - 1]);
            flag = true;
            pos += 2;
            na++;
        }
    }
    if (k % 2 == 0)
    {
        for (int i = n - 1; i > pos + 1; i--)
                swap(a[i], a[i - 1]);
        for (int i = 1; i <= n; i++)
        {
            cout << a[i] << " ";
        }
    }
    else
    {
        swap(a[n], a[n - 1]);
        for (int i = 1; i <= n; i++)
        {
            cout << a[i] << " ";
        }
    }
    }
    else
    {
    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << " ";
    }
    }
}


#include <bits/stdc++.h>
using namespace std;
int n,k,a,b;
int main(){
	cin>>n>>k;
	a=1;
	b=k+1;
	while (1){
		cout<<a<<" ";
		a++;
		if (a>b)break;
		cout<<b<<" ";
		b--;
		if (a>b)break;
	}
	for (int i=k+2;i<=n;i++)cout<<i<<" ";
	cout<<endl;
	return 0;
}


#include <iostream>
using namespace std;
int n,k,i,c[100005],p,j;
int main(){
		   ios::sync_with_stdio(0);
	       cin>>n>>k;
	       for(i=1;i<=n;i++){
	       if(i%2==1){ cout<<i<<" "; c[i]++; p++;}
		    else { cout<<n-i+2<<" "; c[n-i+2]++; p++;}
		    if(p==k) break;
		   }
		   for(j=i;j<=n;j++){
		   	if(c[j]==0) cout<<j<<" ";
		   }
}


#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	#endif // ONLINE_JUDGE
	cin >> n >> k;
	int lastR = n,lastL = 1,last =1;
	map<int,int>mp;
	map<int,int>seen;
	for(int i =0;i<k;i++){
		if(i%2==0){
			if(!seen.count(lastL))
				v.push_back(lastL);
			seen[lastL]++;
			lastL++;
			last = lastL;
		}else{

			lastR = (i+1)+n-(i+1);
			if(!seen.count(lastR))
				v.push_back(lastR);
			seen[lastR]++;
			last = lastR;
		}
	}
	if(last == lastL){
		while(v.size()!=n){
			if(!seen.count(last))
				v.push_back(last);
			last++;
		}
	}else{
		while(v.size()!=n){
			if(!seen.count(last))
				v.push_back(last);
			last--;
		}
	}

	for(int x:v){
			cout << x << " " ;

	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	#endif // ONLINE_JUDGE
	cin >> n >> k;
	int last = 1,j=1;
	for(int i =1;i<=k;i++){
		if(i%2!=0){
			cout << j << " ";
			j++;
			last = j;
		}else{
			cout << n-j+2<< " ";
			last = n-j+2;
		}
	}
	for(int i =last;i<=n-(last-2);i++){
		cout <<i  << " " ;
	}
	for(int i =last-(j-1);i>=j;i--){
		cout <<i  << " " ;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	#endif // ONLINE_JUDGE
	cin >> n >> k;
	int l =1,r=n;
	int i =0;
	for(i =0;i<k;i++){
		if(i%2==0){
			cout << l << " ";
			l++;
		}else{
			cout << r << " ";
			r--;
		}
	}
	if(i%2==0){
		for(int i =r;i>=l;i--){
			cout << i << " " ;
		}
	}else{
		for(int i =l;i<=r;i++){
			cout << i << " ";
		}
	}

	return 0;
}