#include<stdio.h>
#include<stdlib.h>
struct treenode{
    int data;
    struct TreeNode *left ,*right;
};
struct treenode* newNode(int value){
    struct treenode* node= (struct treenode*)malloc(sizeof(struct treenode));
    node->data=value;
    node->left=node->right=NULL;
    return node;
    
}
struct treenode* insert(struct treenode*root,int value){
    if(root == NULL) return newNode(value);
    if(value < root->data){
       root->left= insert(root->left,value);}
    else{
       root->right=insert(root->right,value);
       return root;}
}
void inorder(struct treenode*root){
    if(root!=NULL){
        inorder(root->left);
        printf("%d",root->data);
        inorder(root->right);
    }
}
int main(){
    int N ,X;
    if(scanf("%d,&N")!=1){
        printf("Invalid input");
        return 0;
    }
    if(scanf("%d",&X)!=1){
        printf("Invalid input");
        return 0;
    }
    if(N<0||X<0){
        printf("Invalid input");
        return 0;
    }
    struct treenode*root=NULL;
    for(int i=0;i<N;i++){
        int val;
        if(scanf("%d",&val)!=1){
            printf("Invalid input");
            return 0;
        }
        root =insert(root,val);
    } inorfer(root);
    printf("\n");
    return 0;
}