system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE institution_details (
  unitid integer PRIMARY KEY,
  chronname text,
  city text,
  state text,
  level text,
  control text,
  basic text,
  hbcu text,
  flagship text,
  long_x real,
  lat_y real,
  site text,
  student_count integer,
  awards_per_value real,
  awards_per_state_value real,
  awards_per_natl_value real,
  exp_award_value integer,
  exp_award_state_value integer,
  exp_award_natl_value integer,
  exp_award_percentile integer,
  ft_pct real,
  fte_value integer,
  fte_percentile integer,
  med_sat_value text,
  med_sat_percentile text,
  aid_value integer,
  aid_percentile integer,
  endow_value text,
  endow_percentile text,
  grad_100_value real,
  grad_100_percentile integer,
  grad_150_value real,
  grad_150_percentile integer,
  pell_value real,
  pell_percentile integer,
  retain_value real,
  retain_percentile integer,
  ft_fac_value real,
  ft_fac_percentile integer,
  vsa_year text,
  vsa_grad_after4_first text,
  vsa_grad_elsewhere_after4_first text,
  vsa_enroll_after4_first text,
  vsa_enroll_elsewhere_after4_first text,
  vsa_grad_after6_first text,
  vsa_grad_elsewhere_after6_first text,
  vsa_enroll_after6_first text,
  vsa_enroll_elsewhere_after6_first text,
  vsa_grad_after4_transfer text,
  vsa_grad_elsewhere_after4_transfer text,
  vsa_enroll_after4_transfer text,
  vsa_enroll_elsewhere_after4_transfer text,
  vsa_grad_after6_transfer text,
  vsa_grad_elsewhere_after6_transfer text,
  vsa_enroll_after6_transfer text,
  vsa_enroll_elsewhere_after6_transfer text,
  similar text,
  state_sector_ct integer,
  carnegie_ct integer,
  counted_pct text,
  nicknames text,
  cohort_size integer
);
CREATE TABLE institution_grads (
  unitid integer,
  year integer,
  gender text,
  race text,
  cohort text,
  grad_cohort text,
  grad_100 text,
  grad_150 text,
  grad_100_rate text,
  grad_150_rate text
);
CREATE TABLE state_sector_grads (
  stateid integer,
  state text,
  state_abbr text,
  control text,
  level text,
  year integer,
  gender text,
  race text,
  cohort text,
  grad_cohort text,
  grad_100 text,
  grad_150 text,
  grad_100_rate text,
  grad_150_rate text,
  grad_cohort_ct integer
);
CREATE TABLE state_sector_details (
  stateid integer PRIMARY KEY,
  state text,
  state_post text,
  level text PRIMARY KEY,
  control text PRIMARY KEY,
  schools_count integer,
  counted_pct text,
  awards_per_state_value text,
  awards_per_natl_value real,
  exp_award_state_value text,
  exp_award_natl_value integer,
  state_appr_value text,
  state_appr_rank text,
  grad_rate_rank text,
  awards_per_rank text
);
-- foreign keys: institution_grads.unitid -> institution_details.unitid; state_sector_grads.stateid -> state_sector_details.stateid; state_sector_grads.state -> institution_details.state; state_sector_details.state -> institution_details.state

Hint: male refers to gender = 'M'; graduates refers to grad_cohort; in 2012 refers to year = 2012; highest average amount of student aid going to undergraduate recipients refers to MAX(aid_value);

Question: What is the total male graduates in 2012 in the state whereby the institute with the highest average amount of student aid going to undergraduate recipients is located?

assistant: SELECT COUNT(T2.grad_cohort) FROM institution_details AS T1 INNER JOIN state_sector_grads AS T2 ON T1.state = T2.state WHERE T2.year = 2012 AND T2.gender = 'M' ORDER BY T1.aid_value DESC LIMIT 1