#include #include using namespace std; int main() { int n,x; while (1) { scanf("%d",&n); if (n==0) break; int m=0,f=0; for (int j=0;j