integer function kadomatsu(b) result(n) integer::b(1:3) if ( (b(1).ne.b(3)).and. & ((b(2).gt.b(1).and.b(2).gt.b(3)) .or. & (b(2).lt.b(1).and.b(2).lt.b(3))) ) then n = 1 else n = 0 end if end function kadomatsu program main implicit none interface integer function kadomatsu(b) result(n) integer::b(1:3) end function kadomatsu end interface integer::a(3),b(3),p,total=0 read *,a if ( kadomatsu(a) .eq. 1 ) then print '(a)', "INF" return else if ((a(1).eq.a(2)).or.(a(2).eq.a(3)).or.(a(3).eq.a(1))) then print '(i0)',0 return end if do p=1, MAXVAL(a) b = MOD(a,p) total = total + kadomatsu(b) end do print '(i0)', total end program main