// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <set>
#include <string>
#include <map>
#include <sstream>
#include <list>

using namespace std;
template<typename T>
list<T> merge(list<T> &la, list<T> &lb) {
    list<T> result;
    while (!la.empty() && !lb.empty()) {
        if (la.front() < lb.front()) {
            result.push_back(la.front());
            la.pop_front();
        }
        else {
            result.push_back(lb.front());
            lb.pop_front();
        }
    }

    /* NOTE: the reason why this mergesort doesn't work is that something quite
     * important is missing exactly here. We will fix it next time. */

    return result;
}

template<typename T>
list<T> mergeSort(const list<T> & l)
{
    if (l.empty())
    {
        return l;
    }

    list<list<T>> ll;
    for (auto & i : l)
    {
        ll.push_back(list<T>());
        ll.back().push_back(i);
    }

    while (ll.size() > 1)
    {
        ll.push_back(merge(ll.front(), *(++ll.begin())));
        ll.pop_front();
        ll.pop_front();
    }

    return ll.front();
}

int main()
{
    list<int> la;
    int n;
    while (true) {
        cin >> n;
        if (n == 0) break;
        la.push_back(n);
    }
   
    la = mergeSort(la);

    for (auto && i : la) {
        cout << i << endl;
    }

}

int main2()
{
    int n;
    multiset<int> s;
    while (true)
    {
        cin >> n;
        if (n == 0)
            break;
        s.insert(n);
    }

    /*
    for (set<int>::iterator i = s.begin(); i != s.end(); i++) {
        cout << *i << '\n';
    }
    */
   
    while (!s.empty())
    {
       
        cout << *s.begin() << '\n';
        s.erase(s.begin());
    }
   
    return 0;
}

int main1() {
    string s;
    getline(cin, s);
    stringstream S(s);
    map<string, int> m;
    string t;

    while (S >> t)
    {
        m[t]++;
    }

    for (auto && i :m) {
        cout << i.first << " je char " << i.second << '\n';
    }
    return 0;
}
