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

void transfer(stack<int>s1, stack<int>s2){
    while(!s1.empty()){
        s2.push(s1.top());
        s1.pop();
    }
}
int main(){
    stack<int>s1;
    stack<int>s2;
    stack<int>s3;
    for(int i=0;i<5;i++){
        s1.push(i);
    }

    transfer(s1,s2);
    transfer(s2,s3);
    transfer(s3,s1);
     while(!s1.empty()){
        cout<<s1.top();
        s1.pop();
    }

return 0;}
