#include<iostream>
using namespace std;
typedef struct node {
int data;
struct node* lchild, * rchild;
}node,*snode;
void bst(snode& t,int a) {
if (t == NULL) {
t = new node;
t->data = a;
t->lchild = NULL;
t->rchild = NULL;
return;
}
else if (t->data > a) {
return bst(t->lchild, a);
}
else if (t->data < a) {
return bst(t->rchild, a);
}
}
void printft(snode t,int x) {
if (t == NULL)return;
else {
printft(t->lchild, x);
if (t->data >= x)cout << t->data << " ";
printft(t->rchild, x);
}
}
int main() {
snode t=NULL;
int a;
cin >> a;
while (a != 0) {
bst(t, a);
cin >> a;
}
int x;
cin >> x;
printft(t, x);
}