#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm> 
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include  <ctime>
#include <iomanip>
#include <bitset>
#include <assert.h>   
using namespace std;
 
#define int                  long long int
#define uint                  unsigned long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)          for(int i=(int)a;i<(int)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountint(n)
#define pb                    push_back
#define eb                    emplace_back
#define ab(a)                 (a<0)?(-1*a):a
#define pc                    putchar
#define gc                    getchar
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define mp                    make_pair
#define itoc(c)               ((char)(((int)'0')+c))
#define aint(p)                p.begin(),p.end()
#define max(x,y)              ((x>y)?x:y)
#define min(x,y)              ((x<y)?x:y)
#define mid(s,e)              (s+(e-s)/2)
#define vi                    vector<int>
#define vvi                   vector<vector<int>>
 
const int MOD = 1000000007;
 
int modpow(int a, int b, int mod) { int res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a; res %= mod; a = a * a; a %= mod; }return res; }
int p(int a, int b) { int res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a; a = a * a; }return res; }


int gcd(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

void testcases(int test) {
    int n; cin >> n;
    set<int> ans; ans.insert(1);
    set<int> temp; int prod = 1;
    loop(i,2,n) {
        int x,y;
        int g = gcd(i, n, x, y);
        if(g != 1) continue;
        x = (x%n + n)%n;
        //cout << x << " " << i << "\n";
        if(x == i) { prod *= i; prod%=n; temp.insert(i); continue; }
        ans.insert(x); ans.insert(i);
    }
    if(prod == 1) {
        for(int i : temp) ans.insert(i);
    }
    cout << ans.size() << "\n";
    //cout << ans.size() << " "  << temp.size() << " "  << prod <<  "\n";
    prod = 1;
    for(int i : ans) { prod*= i; prod%=n; cout << i << " ";  }
    assert(prod == 1);
    //for(int i : temp) cout << i << " "; cout << "\n";
}     
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /* code */ 
    int t; 
    // cin >> t;
    t = 1;
    loop(i,0,t) testcases(i);
    /* end code */
}