input: 
  from typing import List
  
  def num_common_substrings(s1: str, s2: str) -> int:
      """ Count the number of common substrings between two given strings.
      >>> num_common_substrings("abcd", "bae")
      2
      >>> num_common_substrings("abc", "def")
      0
      """
  
output:     count = 0
      set1 = set()
      set2 = set()
  
      for i in range(len(s1)):
          for j in range(i + 1, len(s1) + 1):
              set1.add(s1[i:j])
  
      for i in range(len(s2)):
          for j in range(i + 1, len(s2) + 1):
              set2.add(s2[i:j])
  
      for sub in set1:
          if sub in set2:
              count += 1
  
      return count