//StudybarCommentBegin
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    vector<int> arr;
    int i;
    int a;
    for (i = 0; i < 4; i++)
    {
        cin >> a;
        arr.push_back(a);
    }
    vector <int> ::iterator it;
    it = arr.begin();
    //StudybarCommentEnd

    for (; it != arr.end(); ){
        if (*it != 8){ ++it; continue; }

        it = arr.erase(it);
    }

    for (i = 0; i < arr.size(); i++)
    {
        cout << arr[i] << endl;
    }
    return 0;
}