program loginis_reiskinys;
  { 30 u‘davinys }
{----------------------------------------------------------}
  type reiskinys = array [false..true, false..true, false..true]
                         of boolean;

  function priklauso (r : reiskinys) : integer;
    var a, b, c, nep_a, nep_b, nep_c : boolean;
  begin
    { tikrinsime, ar reikžm‚ priklauso nuo kint. a }
    nep_a := true;
    for b := false to true do
      for c := false to true do
        nep_a := nep_a and (r[false, b, c] = r[true, b, c]);
    { tikrinsime, ar reikžm‚ priklauso nuo kint. b }
    nep_b := true;
    for a := false to true do
      for c := false to true do
        nep_b := nep_b and (r[a, false, c] = r[a, true, c]);
    { ir nuo c.. }
    nep_c := true;
    for a := false to true do
      for b := false to true do
        nep_c := nep_c and (r[a, b, false] = r[a, b, true]);
    priklauso := ord (not nep_a) + ord (not nep_b) +
                 ord (not nep_c);
  end;
{----------------------------------------------------------}
  var r : reiskinys;
      a, b, c : boolean;
      ats : 0..1;
      rez : integer;
begin
  writeln ('­veskite loginio reižkinio reikžmes: ');
  writeln ('a   b   c    Reikžm‚');
  writeln ('--------------------');
  for a := false to true do        { vedame pradinius duomenis }
    for b := false to true do
       for c := false to true do
         begin
           write (ord(a), ord(b):4, ord(c):4, ' ':4);
           readln (ats);
           r[a, b, c] := ats = 1;
         end;

   rez := priklauso (r);
   writeln (rez);
end.

