#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef
tree<
  pair<int,int>,
  null_type,
  less<pair<int,int>>,
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,q;
    cin>>n>>q;
    ordered_set s;
    rep(i,0,n){
        int x; cin>>x;
        s.insert({x,i});
    }
    rep(i,0,q){
        int k;
        cin>>k;
        int L=1,U=2e18+5,ans;
        while(L<=U){
            int m=(L+U)/2;
            int cnt=s.order_of_key({m+1,-1});
            if(m-cnt>=k){
                ans=m;
                U=m-1;
            }else L=m+1;
        }
        cout<< ans << endl;
    }
}
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);
ll gcd(ll a, ll b) {if(b == 0) return a; else return gcd(b,a%b);}
ll lcm(ll a, ll b) {return a*b/gcd(a,b);}

int main() {
    int H,W; cin >> H >> W;
    vector<string> S(H); REP(i,H) cin >> S[i];
    int ans = 0;
    REP(i,H) REP(j,W) {
        if(i+1 >= H || j+1 >= W) continue;
        int cnt = 0;
        REP(k,2) REP(l,2) {
            if(S[i+k][j+l] == '.') cnt++;
        }
        if(cnt%2 != 0) ans++;
    }
    cout << ans << endl;
    return 0;
}