#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, long long> > A, B;   void getDivisors(long long x, vector<pair<long long, long long> > &X) {     for (long long i = 1; i * i <= x; i++) {       if (x % i) continue;       X.push_back({i, x / i});     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL), cout.tie(NULL);     long long a, b;     cin >> a >> b;     long long area = a + b;     getDivisors(a, A);     getDivisors(b, B);     long long lim = 0;     while (lim * lim <= area) lim++;     for (long long i = lim - 1; i >= 1; i--) {       if (area % i) continue;       int f = 0;       long long x = i;       long long y = area / i;       int ptr =           lower_bound(A.begin(), A.end(), make_pair(x + 1, 0LL)) - A.begin();       if (ptr > 0 && A[ptr - 1].second <= y) f = 1;       ptr = lower_bound(B.begin(), B.end(), make_pair(x + 1, 0LL)) - B.begin();       if (ptr > 0 && B[ptr - 1].second <= y) f = 1;       if (f == 1) {         cout << (x + y) * 2 <<   n ;         return 0;       }     }     return 0;   }   