
    Given two AI content scanning phases that detected 'a' and 'b' harmful patterns respectively, determine the total number of common pattern categories that were flagged by both scanning algorithms to identify duplicate detection rules. The pattern categories are represented by the common divisors of the two numbers 'a' and 'b', and finding their sum will help optimize the moderation system by eliminating redundant pattern matching rules.
    

    
def sum(a, b):
    """
    Given two AI content scanning phases that detected 'a' and 'b' harmful patterns respectively, determine the total number of common pattern categories that were flagged by both scanning algorithms to identify duplicate detection rules. The pattern categories are represented by the common divisors of the two numbers 'a' and 'b', and finding their sum will help optimize the moderation system by eliminating redundant pattern matching rules.
    

    """
def sum(a, b):
    """
    Given two AI content scanning phases that detected 'a' and 'b' harmful patterns respectively, determine the total number of common pattern categories that were flagged by both scanning algorithms to identify duplicate detection rules. The pattern categories are represented by the common divisors of the two numbers 'a' and 'b', and finding their sum will help optimize the moderation system by eliminating redundant pattern matching rules.
    

    """
    sum = 0
    for i in range(1, min(a, b)):
        if a % i == 0 and b % i == 0:
            sum += i
    return sum