code: public static double method2(ICountFingerprint fp1, ICountFingerprint fp2) {
  
          long maxSum = 0, minSum = 0;
          int i = 0, j = 0;
          while (i < fp1.numOfPopulatedbins() || j < fp2.numOfPopulatedbins()) {
              Integer hash1 = i < fp1.numOfPopulatedbins() ? fp1.getHash(i) : null;
              Integer hash2 = j < fp2.numOfPopulatedbins() ? fp2.getHash(j) : null;
              Integer count1 = i < fp1.numOfPopulatedbins() ? fp1.getCount(i) : null;
              Integer count2 = j < fp2.numOfPopulatedbins() ? fp2.getCount(j) : null;
  
              if (count2 == null || (hash1 != null && hash1 < hash2)) {
                  maxSum += count1;
                  i++;
                  continue;
              }
              if (count1 == null || (hash2 != null && hash1 > hash2)) {
                  maxSum += count2;
                  j++;
                  continue;
              }
  
              if (hash1.equals(hash2)) {
                  maxSum += Math.max(count1, count2);
                  minSum += Math.min(count1, count2);
                  i++;
                  j++;
              }
          }
          return ((double) minSum) / maxSum;
      }
docs: Calculates Tanimoto distance for two count fingerprints using method 2 {@cdk.cite Grant06}.
  
  @param fp1 count fingerprint 1
  @param fp2 count fingerprint 2
  @return a Tanimoto distance