class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param students int整型vector 
     * @param sandwiches int整型vector 
     * @return int整型
     */
    int countStudents(vector<int>& students, vector<int>& sandwiches) {
        queue<int> Students;
        stack<int> Sandwiches;
        reverse(sandwiches.begin(),sandwiches.end());
        int i;
        for(i=0;i<sandwiches.size();i++){
           Sandwiches.push(sandwiches[i]);
        }
        for(i=0;i<students.size();i++){
           Students.push(students[i]);
        }
        int cnt=0;
        while(1){
            if(Students.front()==Sandwiches.top()){
                Students.pop();
                Sandwiches.pop();
                cnt=0;
            }else{
                Students.push(Students.front());
                Students.pop();
                cnt++;
            }
            if(Students.empty()){
                return 0;
            }
            if(cnt==Students.size()){
                return Students.size();
            }
        }
    }
};