Coin Piles problem from cses

if((a+b)%3==0)
how is this true

I solved it using binary search, but it seems like it had a way simpler solution.

void solve() {
    ll n, temp, a, b, ans = 0;
    cin >> a >> b;

    if(a == 2 * b || b == 2 * a) {
         cout << "YES" << endl;
         return;
    }
    if(a == 0 || b == 0) {
         cout << "NO" << endl;
         return;
    }
    ll start = 0, end = max(a, b);
    while(start < end) {
        ll mid = (start + end)/2;
        if(a - mid == 2 * (b - 2 * mid) && a - mid > 0) {
            cout << "YES" << endl;
            return;
        }
        if(a - mid > 2 * (b - 2 * mid)) end = mid;
        else start = mid + 1;
    }
    cout << "NO" << endl;
}