title: ASP Clingo - getting the exact count of atoms
body: <p>I'm looking forward to assign a specific count of persons to a specific shift. For example I got six persons and three different shifts. Now I have to assign exact two persons to every shift. I tried something like this but..<br />
  <strong>NOTE:</strong> this <strong>won't work</strong>, so please edit as fast as possible to misslead people, I even removed the &quot;.&quot; after it so nobody is copying it:</p>
  <pre><code>person(a)
  person(b)
  person(c)
  person(d)
  person(e)
  person(f)
  
  shift(&quot;mor&quot;)
  shift(&quot;aft&quot;)
  shift(&quot;nig&quot;)
  
  shiftCount(2).
  
  { assign(P,S) : shift(S)} = 1 :- person(P).
  
  % DO NOT COPY THIS! SEE RIGHT ANSWER DOWN BELOW
  :- #count{P : assign(P,&quot;mor&quot;)} = K, shiftCount(K).
  :- #count{P : assign(P,&quot;aft&quot;)} = K, shiftCount(K).
  :- #count{P : assign(P,&quot;nig&quot;)} = K, shiftCount(K).
  
  
  #show assign/2.
  </code></pre>
  <p>Is this possible to count the number of assigned shifts, so I can assign exactly as many people as a given number?</p>
  <p>The output of the code above (when the &quot;.&quot; are inserted) is:</p>
  <pre><code>clingo version 5.5.0
  Reading from stdin
  Solving...
  Answer: 1
  assign(a,&quot;nig&quot;) assign(b,&quot;aft&quot;) assign(c,&quot;mor&quot;) assign(d,&quot;mor&quot;)
  assign(e,&quot;mor&quot;) assign(f,&quot;mor&quot;)
  SATISFIABLE
  
  Models       : 1+
  Calls        : 1
  Time         : 0.021s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
  CPU Time     : 0.000s
  </code></pre>
  <p>Here you can defently see, that the morning (&quot;mor&quot;) shift is used more than two times, as difined in the <em>shiftCount</em>. What do I need to change to get the wanted result?</p>