Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <cctype>

using namespace std;

inline int prev(int idx, int size) { idx--; if(idx < 0) idx = size-1; return idx; }
inline void advance(int& idx, int size) { idx++; if(idx == size) idx = 0; }


inline bool isNumber(const string& s, int& ret) {
  ret = -1;
  int tmp = 0;
  int const size=s.size();
  for(int i=0; i<size; i++) {
    if(!isdigit(s[i])) return false;
    (tmp *= 10) += s[i]-'0';
  }
  ret = tmp;
  return true;
}

void remove(vector<int>& player, int& idx) {
  advance(idx, player.size());
  player.erase(player.begin()+prev(idx, player.size()));
  if(idx!=0) idx--;
}

int main() {
  
  int M, N;
  while(cin >> M >> N && (M|N)) {
    int idx = 0;
    vector<int> player(M);
    for(int i=0; i<N; i++) player[i] = i+1;
    for(int fcnt=1; fcnt<=N; fcnt++) {
      string s; cin >> s;
      if(player.size() == 1) continue;
      int num;
      if(s == "Fizz" && fcnt % 3 != 0) remove(player, idx);
      else if(s == "Buzz" && fcnt % 5 != 0) remove(player, idx);
      else if(s == "FizzBuzz" && fcnt % 15 != 0) remove(player, idx);
      else if(isNumber(s, num)) {
        if(num != fcnt) remove(player, idx);
        else if(num % 3 == 0) remove(player, idx);
        else if(num % 5 == 0) remove(player, idx);
        else if(num % 15 == 0) remove(player, idx);
        else advance(idx, player.size());
      }
      else advance(idx, player.size());
    }
    for(int i=0; i<player.size(); i++) {
      if(i) cout << " ";
      cout << player[i];
    }
    cout << endl;
  }
  
  return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h: In instantiation of 'constexpr void std::advance(_InputIterator&, _Distance) [with _InputIterator = int; _Distance = long unsigned int]':
a.cc:25:10:   required from here
   25 |   advance(idx, player.size());
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:223:65: error: no type named 'difference_type' in 'struct std::iterator_traits<int>'
  223 |       typename iterator_traits<_InputIterator>::difference_type __d = __n;
      |                                                                 ^~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:224:56: error: no matching function for call to '__iterator_category(int&)'
  224 |       std::__advance(__i, __d, std::__iterator_category(__i));
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note: candidate: 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&)'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator_base_types.h: In substitution of 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&) [with _Iter = int]':
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:224:56:   required from 'constexpr void std::advance(_InputIterator&, _Distance) [with _InputIterator = int; _Distance = long unsigned int]'
  224 |       std::__advance(__i, __d, std::__iterator_category(__i));
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:25:10:   required from here
   25 |   advance(idx, player.size());
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~