unittest
{
	assert( [ "123456789" ].solve == "Yes" );
	assert( [ "0" ].solve == "Yes" );
	assert( [ "31415926535897932384626433832795028841971693993751058209749445923078164062862089986280" ].solve == "No" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.map!( ( a ) => ( a - '0' ).to!( long ) );
	
	return ( n.sum % 9 == 0 ) ? "Yes" : "No";
}
