Bring water to a boil in large saucepan. Add potatoes and cook until tender. Drain, reserving liquid. Set aside potatoes. Measure 1 cup of cooking liquid, adding water, if necessary and set aside.
Peel and finely chop onion. Melt butter in saucepan over medium heat. Add onion to saucepan and cook, stirring frequently, until onion is translucent and tender, but not brown.
Add flour to saucepan. Season with pepper flakes and black pepper to taste. Cook 3 to 4 minutes.
Gradually add potatoes, reserved 1 cup cooking liquid, milk and sugar to onion mixture in saucepan. Stir well. Add cheese and ham and simmer over low heat for 30 minutes, stirring frequently. Store leftovers, covered, in refrigerator.