#include #include #define rep( i, n, m ) for(ll i = ( n ); i < ( m ); i++) using ll = long long int; int give_water( int* array, int begin, int end ); int main( void ){ int n, k; if (!scanf( "%d %d", &n, &k )) return 0; k--; ll* position = new ll( n * 2 ); rep( i, 0, n ){ if (!scanf( "%lld", position + i )) return 0; } rep( i, 0, n ){ if (!scanf( "%lld", position + i + n )) return 0; } ll area[ 2 ]; area[ 0 ] = position[ k ] - position[ n + k ]; area[ 1 ] = position[ k ] + position[ n + k ]; bool can = true; while(can){ can = false; rep( i, 0, n ){ if( area[ 0 ] <= position[ i ] && position[ i ] <= area[ 1 ]){ if(area[ 0 ] > position[ i ] - position[ n + i ]){ area[ 0 ] = position[ i ] - position[ n + i ]; can = true; } if(area[ 1 ] < position[ i ] + position[ n + i ]){ area[ 1 ] = position[ i ] + position[ n + i ]; can = true; } } } } int sum = 0; rep( i, 0, n ){ if(area[ 0 ] <= position[ i ] && position[ i ] <= area[ 1 ]) sum++; } printf( "%d\n", sum ); return 0; }